:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --secondary: #f43f5e;
    --accent: #10b981;
    
    /* Study Theme (Light/Modern) */
    --bg-study: #f8fafc;
    --card-study: rgba(255, 255, 255, 0.8);
    --text-study: #0f172a;
    --text-muted: #64748b;
    --border-study: rgba(226, 232, 240, 0.8);
    
    /* Chat Vault (Dark/Deep) */
    --bg-chat: #0f172a;
    --card-chat: #1e293b;
    --text-chat: #f8fafc;
    --border-chat: rgba(255, 255, 255, 0.05);

    --radius-lg: 24px;
    --radius-md: 16px;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
}

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', -apple-system, sans-serif;
}

body {
    background: var(--bg-study);
    color: var(--text-study);
    min-height: 100vh;
    transition: background 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-font-smoothing: antialiased;
}

/* --- PREMIUM UI COMPONENTS --- */

.glass-card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.btn-premium {
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 10px 15px -3px var(--primary-glow);
}

.btn-premium:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 20px 25px -5px var(--primary-glow);
}

.btn-premium:active {
    transform: translateY(1px);
    box-shadow: 0 5px 10px -2px var(--primary-glow);
}

.btn-premium.secondary {
    background: white;
    color: var(--text-study);
    border: 1px solid var(--border-study);
    box-shadow: var(--shadow-sm);
}

/* --- DASHBOARD LAYOUT --- */

.dashboard-container {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 30px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 30px;
    height: 100vh;
    overflow: hidden;
}

/* --- RESPONSIVE LAYOUT --- */
.mobile-bar {
    display: none;
    padding: 15px 25px;
    background: white;
    box-shadow: var(--shadow-sm);
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

@media (max-width: 1100px) {
    .dashboard-container { 
        grid-template-columns: 240px 1fr; 
        height: auto; 
        overflow: visible; 
    }
    .right-sidebar { 
        grid-column: 1 / -1; 
        flex-direction: row; 
        height: auto;
    }
    .right-sidebar > div { flex: 1; }
}

@media (max-width: 850px) {
    .mobile-bar { display: flex; }
    .dashboard-container { 
        grid-template-columns: 1fr; 
        padding: 20px;
        height: auto;
        overflow: visible;
    }
    .main-content { height: auto; overflow: visible; padding-right: 0; }
    
    .right-sidebar {
        grid-column: 1;
        flex-direction: column;
        width: 100%;
        height: auto;
    }
    
    .left-sidebar { 
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        background: white;
        padding: 40px 30px;
        transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 20px 0 50px rgba(0,0,0,0.1);
    }
    
    .left-sidebar.active {
        left: 0;
        padding: 40px 25px;
    }
    
    .left-sidebar.active ~ .main-content {
        filter: blur(4px);
        pointer-events: none;
    }
}
    height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.main-content {
    height: calc(100vh - 60px);
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-width: thin;
}

.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 10px; }

/* --- SIDEBAR NAV --- */
.nav-category {
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    transition: 0.2s;
}

.nav-category:hover, .nav-category.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* --- STUDY CARDS --- */
.study-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.note-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-study);
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.note-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--primary);
    opacity: 0.1;
}

.note-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.note-badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

/* --- POMODORO TIMER --- */
.timer-container {
    padding: 30px;
    text-align: center;
}

.timer-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 8px solid #f1f5f9;
    border-top: 8px solid var(--primary);
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    transition: transform 0.3s ease;
}

.timer-active .timer-circle {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 15px rgba(99, 102, 241, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

/* --- CHAT VAULT --- */
.mode-chat {
    height: 100vh;
    overflow: hidden;
    background: #0b1018;
}

.chat-grid {
    display: grid;
    grid-template-columns: 360px 1fr;
    height: 100vh;
}

@media (max-width: 900px) {
    .chat-grid { grid-template-columns: 1fr; }
    
    .chat-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex !important; /* always mounted, transition hides it */
    }
    
    .chat-sidebar.active {
        transform: translateX(0);
    }
}

.chat-sidebar {
    background: #111827;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.05);
    color: #e5e7eb;
    overflow: hidden;
}

.chat-sidebar h2 { color: #f3f4f6; }
.chat-sidebar .user-name { color: #f3f4f6; font-weight: 600; }
.chat-sidebar p { color: #94a3b8; }

.chat-main {
    background: #0b1018;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100vh;
}

.user-item {
    margin: 4px 12px;
    padding: 12px 15px;
    border-radius: 12px;
    transition: 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
}
.user-item:hover { background: rgba(255,255,255,0.04); }
.user-item.active { background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.2); }

/* --- MESSAGES --- */
.message-bubble {
    max-width: 72%;
    padding: 11px 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
    word-break: break-word;
    border-radius: 18px;
    margin-bottom: 2px;
}

.message.sent .message-bubble {
    background: #6366f1;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: #1f2937;
    color: #f1f5f9;
    border-bottom-left-radius: 4px;
}

.message-img {
    max-width: 100%;
    max-height: 260px;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
    display: block;
    margin-top: 5px;
}
.message-img:hover { transform: scale(1.02); }

#messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#messages-container::-webkit-scrollbar { width: 4px; }
#messages-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 10px; }

#active-chat { display: none; flex-direction: column; height: 100%; overflow: hidden; }
#active-chat footer { padding: 15px 20px; flex-shrink: 0; }

.chat-header {
    padding: 14px 24px;
    background: #111827;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}

.chat-footer {
    padding: 14px 20px;
    flex-shrink: 0;
}

.chat-form-inner {
    display: flex;
    gap: 12px;
    align-items: center;
    background: #1f2937;
    padding: 10px 16px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
}

@media (max-width: 500px) {
    .chat-header { padding: 12px 15px; }
    .chat-footer { padding: 10px 12px; }
    .chat-form-inner { gap: 8px; padding: 8px 12px; border-radius: 14px; }
}

/* Chat header */
#chat-header-name { color: #f3f4f6; font-weight: 700; font-size: 1rem; }
#chat-header-status { font-size: 0.75rem; color: #64748b; }

/* --- ICON BUTTONS --- */
.btn-icon {
    background: rgba(255,255,255,0.05);
    border: none;
    color: #94a3b8;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: 0.2s;
    flex-shrink: 0;
}
.btn-icon:hover { background: rgba(255,255,255,0.1); color: white; }

/* Show hamburger button inside chat on mobile */
@media (max-width: 900px) {
    #show-sidebar { display: flex !important; }
}

/* --- CHAT EXPIRY SELECT --- */
.chat-setting-select {
    background: #1f2937;
    color: #94a3b8;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
    font-family: inherit;
}
.chat-setting-select:focus { border-color: var(--primary); }
.chat-setting-select option { background: #1f2937; color: #f3f4f6; }

/* --- PIN MODAL --- */
.pin-modal {
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 24px;
    padding: 50px 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

@media (max-width: 500px) {
    .pin-modal { padding: 40px 25px; }
    .message-bubble { max-width: 88%; }
    #active-chat footer { padding: 10px 12px; }
    .chat-form-inner { gap: 10px !important; padding: 8px 14px !important; }
}

/* --- MODALS (shared) --- */
.pin-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(16px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.input-field {
    width: 100%;
    padding: 14px 20px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 1rem;
    margin-bottom: 20px;
    outline: none;
    transition: 0.3s;
    font-family: inherit;
    box-sizing: border-box;
}
.input-field:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99,102,241,0.1);
}

/* --- TASKS --- */
.task-item {
    background: white;
    padding: 14px 16px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    border: 1px solid var(--border-study);
    width: 100%;
    box-sizing: border-box;
}

.task-checkbox {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border-radius: 6px;
    border: 2px solid #cbd5e1;
    cursor: pointer;
    transition: 0.2s;
    flex-shrink: 0;
}
.task-checkbox:hover { border-color: var(--primary); }
.task-item.completed { opacity: 0.5; }
.task-item.completed .task-text { text-decoration: line-through; }

/* Status dots */
.status-online { background: #10b981 !important; }
.status-offline { background: #64748b !important; }

/* Mobile-only elements */
.mobile-only { display: none !important; }
@media (max-width: 900px) {
    .mobile-only { display: flex !important; }
}
