/* ============================================================
   InMyMind Web UI — Dark theme, mobile-first
   ============================================================ */

:root {
    /* Palette */
    --bg-primary:   #0f0f1a;
    --bg-secondary: #181828;
    --bg-card:      rgba(30, 30, 50, 0.7);
    --bg-card-alt:  rgba(40, 40, 65, 0.6);
    --bg-input:     #1e1e32;
    --bg-hover:     #252540;

    --text-primary:   #e8e8f0;
    --text-secondary: #9090b0;
    --text-muted:     #606080;

    --accent:       #6c5ce7;
    --accent-glow:  rgba(108, 92, 231, 0.3);
    --accent-light: #a29bfe;

    --success:  #00cec9;
    --error:    #ff6b6b;
    --warning:  #feca57;

    --border:   rgba(255, 255, 255, 0.06);
    --shadow:   rgba(0, 0, 0, 0.4);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Sizing */
    --radius:    12px;
    --radius-sm: 8px;
    --header-h:  56px;
    --input-h:   64px;
    --quick-h:   48px;

    /* Safe area for PWA on notched phones */
    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left:   env(safe-area-inset-left, 0px);
    --safe-right:  env(safe-area-inset-right, 0px);
}

/* ---- Reset ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   Layout shell
   ============================================================ */

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 640px;
    margin: 0 auto;
    position: relative;
}

/* ---- Header ---- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    padding: 0 16px;
    padding-top: var(--safe-top);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    font-size: 24px;
    line-height: 1;
}

.header-title {
    font-weight: 700;
    font-size: 18px;
    background: linear-gradient(135deg, var(--accent-light), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 18px;
    transition: background 0.2s, color 0.2s;
}

.btn-logout:hover {
    background: var(--bg-hover);
    color: var(--error);
}

/* ---- Quick actions ---- */
.quick-actions {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    overflow-x: auto;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
}

.quick-actions::-webkit-scrollbar {
    display: none;
}

.quick-btn {
    flex-shrink: 0;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-btn:hover,
.quick-btn:active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* ---- Chat area ---- */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar {
    width: 4px;
}

.chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 2px;
}

/* Welcome */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.welcome-hint {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.welcome-hint code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-light);
}

/* ---- Chat messages ---- */
.msg {
    animation: msgIn 0.3s ease-out;
}

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

.msg-user {
    align-self: flex-end;
    max-width: 85%;
    padding: 10px 14px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius) var(--radius) 4px var(--radius);
    font-family: var(--font-mono);
    font-size: 14px;
    word-break: break-word;
}

.msg-bot {
    align-self: flex-start;
    max-width: 90%;
    padding: 14px 16px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 4px var(--radius) var(--radius) var(--radius);
    word-break: break-word;
}

.msg-bot.error {
    border-color: rgba(255, 107, 107, 0.3);
    background: rgba(255, 107, 107, 0.08);
}

.msg-bot pre {
    font-family: var(--font-mono);
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
    color: var(--text-primary);
}

.msg-bot .file-link {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.msg-bot .file-link:hover {
    background: var(--accent-light);
}

/* Loading dots */
.msg-loading {
    align-self: flex-start;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px var(--radius) var(--radius) var(--radius);
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.1); }
}

/* ---- Input bar ---- */
.input-bar {
    flex-shrink: 0;
    padding: 10px 16px;
    padding-bottom: calc(10px + var(--safe-bottom));
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

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

#commandInput {
    flex: 1;
    height: 44px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#commandInput::placeholder {
    color: var(--text-muted);
}

#commandInput:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}

.btn-send:hover {
    background: var(--accent-light);
    transform: scale(1.05);
}

.btn-send:active {
    transform: scale(0.95);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ============================================================
   Login page
   ============================================================ */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: auto;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.12), transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 206, 201, 0.08), transparent 50%),
        var(--bg-primary);
}

.login-container {
    width: 100%;
    max-width: 380px;
    padding: 24px;
}

.login-card {
    padding: 40px 32px;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 8px 40px var(--shadow);
}

.login-logo {
    font-size: 48px;
    margin-bottom: 12px;
    animation: float 3s ease-in-out infinite;
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-light), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-error {
    padding: 10px 14px;
    margin-bottom: 16px;
    background: rgba(255, 107, 107, 0.12);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 14px;
}

.login-form .input-group {
    margin-bottom: 16px;
}

.login-form input[type="password"] {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input[type="password"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-login {
    width: 100%;
    height: 48px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent), #8b7cf7);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-login:active {
    transform: translateY(0);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 480px) {
    .login-card {
        padding: 32px 24px;
    }

    .quick-btn {
        padding: 5px 12px;
        font-size: 12px;
    }
}
