/*
    Talaga - Premium Design System
    Mobile-First Responsive Architecture
    Breakpoints: 480px | 768px | 1024px | 1280px
*/

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #a855f7;
    --accent: #f43f5e;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    --bg-dark: #0b0f1a;
    --bg-surface: #131a2b;
    --bg-card: rgba(19, 26, 43, 0.85);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.05);

    --shadow-sm: 0 4px 6px -1px rgba(0,0,0,0.15);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.25);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.35);
    --glow: 0 0 20px rgba(99, 102, 241, 0.3);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    /* Touch-friendly minimum target */
    --touch: 44px;

    /* iOS Safe Areas */
    --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);
}

/* Ultra Dark Theme */
body.ultra-dark {
    --bg-dark: #000;
    --bg-surface: #0a0a0a;
    --bg-card: rgba(0,0,0,0.9);
    --glass-bg: rgba(20,20,20,0.4);
    --glass-border: rgba(255,255,255,0.05);
    --primary: #4f46e5;
}

/* ============================================
   RESET
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
    font-size: 16px;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100dvh;
    width: 100vw;
    line-height: 1.5;
}

.hidden { display: none !important; }
.flex { display: flex !important; }

/* Scrollbars */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* Focus ring */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ============================================
   APP LAYOUT (Mobile First: column stack)
   ============================================ */
#app-root {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100vw;
    background:
        radial-gradient(circle at 0% 0%, rgba(99,102,241,0.08) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(168,85,247,0.08) 0%, transparent 50%),
        var(--bg-dark);
    overflow: hidden;
    position: relative;
}

/* ============================================
   MOBILE HEADER
   ============================================ */
.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    padding-top: calc(0.75rem + var(--safe-top));
    background: rgba(11,15,26,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-shrink: 0;
    min-height: var(--touch);
}

.menu-toggle {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.35rem;
    cursor: pointer;
    min-width: var(--touch);
    min-height: var(--touch);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: var(--transition);
    flex-shrink: 0;
}
.menu-toggle:hover { background: var(--glass-highlight); }

/* ============================================
   NAVIGATION SIDEBAR
   ============================================ */
#main-nav {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100dvh;
    z-index: 2000;
    background: var(--bg-dark);
    border-right: 1px solid var(--glass-border);
    display: flex !important;
    flex-direction: column;
    padding: 1.75rem 1.25rem;
    padding-top: calc(1.75rem + var(--safe-top));
    padding-bottom: calc(1.75rem + var(--safe-bottom));
    overflow-y: auto;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#main-nav.open {
    transform: translateX(280px);
    box-shadow: 20px 0 80px rgba(0,0,0,0.7);
}

#main-nav.hidden { display: none !important; }

/* Nav backdrop overlay */
#nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
#nav-overlay.active { display: block; }

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 2.75rem;
    padding: 0 0.25rem;
    flex-shrink: 0;
}

.logo-img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    filter: drop-shadow(var(--glow));
    flex-shrink: 0;
}

.brand-name {
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links { list-style: none; flex: 1; overflow-y: auto; }

.nav-links li {
    padding: 0.85rem 1rem;
    margin-bottom: 0.3rem;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
    transition: var(--transition);
    border: 1px solid transparent;
    min-height: var(--touch);
    user-select: none;
    -webkit-user-select: none;
}

.nav-links li:hover {
    background: var(--glass-highlight);
    color: var(--text-main);
    padding-left: 1.25rem;
}

.nav-links li.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 6px 18px rgba(99,102,241,0.3);
    border-color: rgba(255,255,255,0.1);
}

.nav-links li i { width: 20px; font-size: 1.1rem; flex-shrink: 0; }

.nav-footer {
    padding-top: 1.25rem;
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
}

.nav-item-btn {
    width: 100%;
    padding: 0.85rem 1rem;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
    min-height: var(--touch);
}
.nav-item-btn:hover { color: var(--accent); background: rgba(244,63,94,0.05); }

/* ============================================
   MAIN CONTENT
   ============================================ */
#main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.25rem 1rem;
    padding-bottom: calc(1.25rem + var(--safe-bottom));
    position: relative;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: var(--transition);
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--glass-border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

/* ============================================
   AUTH
   ============================================ */
.auth-container {
    width: 100%;
    max-width: 420px;
    margin: 3rem auto 2rem;
    background: var(--bg-card);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    padding: 2.5rem 1.75rem;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.google-btn {
    width: 100%;
    padding: 1rem;
    min-height: var(--touch);
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.05);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    transition: var(--transition);
}
.google-btn:hover { background: rgba(255,255,255,0.1); transform: translateY(-1px); border-color: var(--primary); }
.google-btn:active { transform: translateY(0); }

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 0.85rem 1.5rem;
    min-height: var(--touch);
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    box-shadow: 0 4px 15px rgba(99,102,241,0.3);
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(99,102,241,0.4); }
.btn-primary:active { transform: translateY(0); }

.delete-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 0.4rem;
    min-width: 36px;
    min-height: 36px;
    border-radius: 8px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.delete-btn:hover { background: rgba(239,68,68,0.1); color: var(--error); }

/* ============================================
   INPUTS & FORMS
   ============================================ */
input, textarea, select {
    width: 100%;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
    min-height: var(--touch);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255,255,255,0.06);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

textarea { min-height: auto; resize: vertical; }

select option { background: var(--bg-surface); color: white; }

select.modal-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 1.1rem;
    padding-right: 2.75rem !important;
    cursor: pointer;
}

.modal-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    outline: none;
    font-family: inherit;
    min-height: auto;
}
.modal-input:focus { box-shadow: none; border: none; }

/* ============================================
   NOTES GRID (Mobile: 1 col by default)
   ============================================ */
.notes-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    animation: slideUp 0.6s ease-out;
}

.note-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 1.35rem;
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.note-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: var(--transition);
}
.note-card:hover { transform: translateY(-4px); border-color: var(--primary-light); box-shadow: var(--shadow-md); }
.note-card:hover::before { opacity: 1; }

.note-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }

.note-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
    word-break: break-word;
}

.note-card p {
    font-size: 0.88rem;
    color: var(--text-dim);
    line-height: 1.6;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

.note-card-footer { font-size: 0.78rem; color: var(--text-muted); margin-top: auto; }

/* ============================================
   CATEGORY BADGES
   ============================================ */
.note-category-badge {
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.badge-todo    { background: rgba(16,185,129,0.1); color: var(--success); }
.badge-account { background: rgba(245,158,11,0.1); color: var(--warning); }
.badge-info    { background: rgba(99,102,241,0.1); color: var(--primary-light); }
.badge-business{ background: rgba(168,85,247,0.1); color: var(--secondary); }
.badge-student { background: rgba(59,130,246,0.1); color: #3b82f6; }
.badge-personal{ background: rgba(244,63,94,0.1); color: var(--accent); }
.badge-other   { background: rgba(148,163,184,0.1); color: var(--text-muted); }

/* ============================================
   MODAL — Mobile: Bottom Sheet
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 3000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-height: 93dvh;
    padding: 1.5rem 1.25rem;
    padding-bottom: calc(1.5rem + var(--safe-bottom));
    animation: slideUpModal 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ============================================
   SETTINGS
   ============================================ */
.settings-group {
    margin-bottom: 1.5rem;
    padding: 1.5rem 1.25rem;
    background: var(--glass-bg);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    gap: 1rem;
}
.settings-row:not(:last-child) { border-bottom: 1px solid var(--glass-border); }

/* ============================================
   SWITCH TOGGLE
   ============================================ */
.switch { position: relative; display: inline-block; width: 50px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--glass-border);
    transition: 0.3s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 4px; bottom: 4px;
    background: white;
    transition: 0.3s;
}
input:checked + .slider { background: var(--primary); }
input:checked + .slider:before { transform: translateX(24px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
#toast-container {
    position: fixed;
    bottom: calc(1.5rem + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    z-index: 9998;
    width: calc(100vw - 2rem);
    max-width: 420px;
    pointer-events: none;
}

.toast {
    background: var(--bg-surface);
    color: white;
    padding: 0.85rem 1.25rem;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    animation: slideInBottom 0.3s ease-out;
    width: 100%;
    font-size: 0.9rem;
    pointer-events: all;
}
.toast-success i { color: var(--success); }
.toast-error i { color: var(--accent); }
.toast-info i { color: var(--primary-light); }

/* ============================================
   HELP CARDS
   ============================================ */
.help-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; margin-top: 1.5rem; }

.help-card {
    padding: 1.25rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    transition: var(--transition);
}
.help-card:hover { border-color: var(--primary-light); transform: translateY(-3px); }

/* Page transition */
.view-enter { animation: slideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* Fullscreen modal override */
.fullscreen-overlay { padding: 0 !important; }
.fullscreen-modal { margin: 0 !important; max-width: 100% !important; height: 100dvh !important; border-radius: 0 !important; border: none !important; }

/* Reduced motion */
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideUpModal {
    from { opacity: 0; transform: translateY(60px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInBottom {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   BREAKPOINT: 480px (Large Mobile)
   ============================================ */
@media (min-width: 480px) {
    #main-content { padding: 1.5rem 1.5rem; }
    .auth-container { padding: 3rem 2.25rem; }
    .notes-grid { gap: 1.25rem; }
}

/* ============================================
   BREAKPOINT: 768px (Tablet)
   ============================================ */
@media (min-width: 768px) {
    #app-root { flex-direction: row; }

    .mobile-header { display: none; }

    #main-nav {
        position: relative;
        top: auto; left: auto;
        width: 260px;
        height: 100dvh;
        transform: none !important;
        box-shadow: none !important;
        padding: 2rem 1.5rem;
        border-right: 1px solid var(--glass-border);
        background: var(--glass-bg);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-shrink: 0;
    }

    #nav-overlay { display: none !important; }

    #main-content { padding: 2.5rem 2rem; }

    .notes-grid { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }

    .modal-overlay {
        align-items: center;
        padding: 2rem;
    }
    .modal-content {
        border-radius: 24px;
        max-width: 680px;
        max-height: 88dvh;
        padding: 2rem 2.25rem;
    }

    .auth-container { margin: 8rem auto; }

    .help-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================
   BREAKPOINT: 1024px (Laptop)
   ============================================ */
@media (min-width: 1024px) {
    #main-nav { width: 280px; padding: 2.5rem 1.75rem; }

    #main-content { padding: 3rem 2.5rem; }

    .notes-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.75rem; }

    .modal-content { max-width: 700px; padding: 2.5rem; }

    .note-card { padding: 1.75rem; }
    .note-card h3 { font-size: 1.1rem; }
}

/* ============================================
   BREAKPOINT: 1280px (Desktop)
   ============================================ */
@media (min-width: 1280px) {
    #main-nav { width: 290px; }
    #main-content { padding: 3rem 3.5rem; }
    .notes-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 2rem; }
}

/* ============================================
   DASHBOARD HEADER — Mobile Responsive
   ============================================ */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.dashboard-header h1 { font-size: clamp(1.5rem, 4vw, 2rem); }

/* ============================================
   IMAGES & MEDIA — Always Responsive
   ============================================ */
img, video, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ============================================
   QUILL EDITOR CUSTOM THEME (Dark)
   ============================================ */
.ql-toolbar.ql-snow {
    background: var(--bg-surface) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 12px 12px 0 0 !important;
    padding: 10px !important;
}

.ql-container.ql-snow {
    border: 1px solid var(--glass-border) !important;
    border-top: none !important;
    border-radius: 0 0 12px 12px !important;
    font-family: 'Outfit', sans-serif !important;
    font-size: 1.1rem !important;
    background: rgba(255, 255, 255, 0.02) !important;
}

.ql-editor {
    min-height: 300px;
    color: var(--text-main) !important;
}

.ql-editor.ql-blank::before {
    color: var(--text-dim) !important;
    font-style: normal !important;
}

/* Style the toolbar icons */
.ql-snow .ql-stroke { stroke: var(--text-muted) !important; }
.ql-snow .ql-fill { fill: var(--text-muted) !important; }
.ql-snow .ql-picker { color: var(--text-muted) !important; }

.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-fill {
    stroke: var(--primary) !important;
    fill: var(--primary) !important;
}

/* ============================================
   NOTE CONTENT DISPLAY (Read Mode)
   ============================================ */
.note-content-display img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 1rem 0;
    border: 1px solid var(--glass-border);
    transition: var(--transition);
}

.note-content-display img:hover {
    box-shadow: var(--glow);
    transform: scale(1.01);
}

/* Lightbox Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive Fixes for Quill */
@media (max-width: 600px) {
    .ql-toolbar.ql-snow {
        padding: 5px !important;
    }
    .ql-formats {
        margin-right: 5px !important;
    }
}

