/* Design Tokens & Theme Variable */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #131926;
    --bg-glass: rgba(19, 25, 38, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --accent-blue: #00f2fe;
    --accent-purple: #4facfe;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --message-user: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    --message-model: #1e293b;
    --gradient-primary: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    --font-heading: 'Outfit', -apple-system, sans-serif;
    --font-body: 'Plus Jakarta Sans', -apple-system, sans-serif;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Reset & Base Rules */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 15px;
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

/* App Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    background-color: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    position: relative;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand h1 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 1.5px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-blue);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-blue);
    animation: pulse 2s infinite;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.status-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-indicator.online {
    background-color: #10b981;
    box-shadow: 0 0 6px #10b981;
}

/* Main Area & Navigation */
.app-main {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.tab-content {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: calc(20px + var(--safe-area-bottom));
}

.tab-content.active {
    display: flex;
}

/* Chat Messages */
#tab-chat {
    padding: 0;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.model {
    align-self: flex-start;
}

.avatar {
    width: 32px;
    height: 32px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
}

.bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14.5px;
    word-break: break-word;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.message.user .bubble {
    background: var(--message-user);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.model .bubble {
    background: var(--message-model);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Chat Input Form */
.chat-input-container {
    padding: 12px 16px calc(12px + var(--safe-area-bottom));
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.chat-input-container form {
    display: flex;
    gap: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 6px 6px 6px 14px;
    border-radius: 24px;
    align-items: center;
}

.chat-input-container input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 14.5px;
    font-family: var(--font-body);
}

.chat-input-container input:focus {
    outline: none;
}

.chat-input-container button {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-input-container button:active {
    transform: scale(0.92);
}

.chat-input-container button svg {
    width: 16px;
    height: 16px;
    transform: translateX(1px);
}

/* Notes & Memory Form Styles */
.notes-container, .memory-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 80px;
}

.notes-header h2, .memory-header h2 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.notes-header p, .memory-header p {
    color: var(--text-muted);
    font-size: 13px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input, .form-group textarea {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 14px;
}

.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 8px rgba(0, 242, 254, 0.2);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    font-weight: 600;
    padding: 14px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--font-body);
    width: 100%;
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
    transition: transform 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
}

/* Memory Cards */
.memory-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.memory-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.2s;
}

.memory-card:hover {
    border-color: rgba(0, 242, 254, 0.4);
}

.memory-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.memory-card-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 16px;
    color: var(--accent-blue);
}

.memory-card-date {
    font-size: 11px;
    color: var(--text-muted);
}

.memory-card-body {
    font-size: 13.5px;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 150px;
    overflow-y: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 8px;
}

/* Bottom Nav */
.app-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--bg-glass);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-top: 1px solid var(--border-color);
    padding: 10px 10px calc(10px + var(--safe-area-bottom));
    z-index: 10;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-family: var(--font-body);
    font-size: 11px;
    cursor: pointer;
    flex: 1;
    transition: color 0.2s;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    transition: transform 0.2s;
}

.nav-item.active {
    color: var(--accent-blue);
}

.nav-item.active svg {
    transform: translateY(-2px);
    color: var(--accent-blue);
}

/* Toast */
.toast {
    position: absolute;
    bottom: 80px;
    left: 20px;
    right: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-blue);
    padding: 12px 16px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    z-index: 99;
}

.toast.hidden {
    display: none;
}

.toast button {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 14px var(--accent-blue); }
    100% { transform: scale(1); opacity: 0.6; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.loading-spinner {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px;
}

/* Login Screen Style */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.login-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.login-card h2 {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 24px;
    letter-spacing: 1px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-card p {
    color: var(--text-muted);
    font-size: 13px;
}

.login-card input {
    width: 100%;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 14px;
    border-radius: 12px;
    text-align: center;
    font-size: 16px;
    font-family: var(--font-body);
}

.login-card input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.login-error-msg {
    color: #ef4444;
    font-size: 12px;
    margin-top: 5px;
}

.login-error-msg.hidden {
    display: none;
}

.login-overlay.hidden {
    display: none;
}
