/* My Canned Notes Pro - Clean Dashboard Theme */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --secondary: #1E40AF;
    --accent: #F472B6;

    --bg-app: #f8fafc;
    --bg-panel: #ffffff;
    --bg-sidebar: #0f172a;

    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-on-dark: #e2e8f0;

    --border-light: #e2e8f0;
    --border-focus: #bfdbfe;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* ===== LAYOUT ===== */
body {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
    margin: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: row;
}

/* ===== SIDEBAR ===== */
.app-sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-on-dark);
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    flex-shrink: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: white;
}

.brand-text {
    font-weight: 700;
    font-size: 16px;
    color: white;
}

.new-chat-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    color: white;
    padding: 12px;
    border-radius: var(--radius-md);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 24px;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    margin-top: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.1);
}

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #059669);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.user-info {
    flex: 1;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: white;
}

.user-credits {
    font-size: 11px;
    color: #94a3b8;
}

/* ===== MAIN STAGE ===== */
.main-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-app);
    overflow: hidden;
}

.top-bar {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: var(--bg-panel, #ffffff);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.view-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--text-main);
}

/* ===== CONTENT VIEWS ===== */
/* Override style.css flex !important rules for dashboard layout */
/* Content views are direct children of .main-stage */
.main-stage > .content-view {
    display: none !important;
    padding: 24px 40px;
    min-height: 0;
    box-sizing: border-box;
    height: auto !important;
    flex: none !important;
    flex-direction: unset !important;
    overflow: visible !important;
}

.main-stage > .content-view.active {
    display: block !important;
    height: auto !important;
    flex: none !important;
    overflow-y: auto !important;
    flex: 1 !important;
}

/* AI view — special: needs flex column for magical layout */
.main-stage > #aiView.active {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    flex: 1 !important;
    overflow: hidden !important;
}

/* Specific adjustments for different views */
#templatesView,
#historyView,
#settingsView,
#userOverview {
    padding-top: 24px;
}

/* ===== AI VIEW ===== */
#aiView {
    background: linear-gradient(135deg,
            #667eea 0%,
            #764ba2 25%,
            #f093fb 50%,
            #4facfe 75%,
            #00f2fe 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    padding: 0;
    position: relative;
    overflow: hidden;
}

#aiView::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: rotate 20s linear infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes rotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.hero-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 80px 40px 40px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.greeting-text {
    font-size: 48px;
    font-weight: 800;
    margin-bottom: 16px;
    color: white;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 40px rgba(255, 255, 255, 0.2);
    letter-spacing: -0.5px;
    animation: fadeInUp 0.8s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.subtitle-text {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 50px;
    font-weight: 400;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    animation: fadeInUp 0.8s ease 0.2s both;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 50px;
    animation: fadeInUp 0.8s ease 0.4s both;
}

.feature-card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    padding: 32px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    text-align: left;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    opacity: 0;
    transition: opacity 0.4s;
}

.feature-card:hover::before {
    opacity: 1;
}

.feature-card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
}

.feature-card .icon-box {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #667eea, #764ba2, #f093fb);
    background-size: 200% 200%;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    margin-bottom: 20px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
    position: relative;
    z-index: 1;
    animation: iconGlow 3s ease-in-out infinite;
}

@keyframes iconGlow {

    0%,
    100% {
        box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
    }

    50% {
        box-shadow: 0 8px 32px rgba(240, 147, 251, 0.6);
    }
}

.feature-card h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: var(--text-main);
    position: relative;
    z-index: 1;
}

.feature-card p {
    font-size: 15px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.7;
    position: relative;
    z-index: 1;
}

.ai-composer {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 28px;
    max-width: 750px;
    margin: 0 auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    animation: fadeInUp 0.8s ease 0.6s both;
}

.ai-composer textarea {
    width: 100%;
    border: none;
    outline: none;
    font-size: 17px;
    font-family: inherit;
    resize: none;
    min-height: 120px;
    color: var(--text-main);
    background: transparent;
    line-height: 1.6;
}

.ai-composer textarea::placeholder {
    color: var(--text-muted);
}

.ai-composer-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.credit-info {
    font-size: 14px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.btn-send {
    background: linear-gradient(135deg, #667eea, #764ba2, #f093fb);
    background-size: 200% 200%;
    color: white;
    border: none;
    padding: 14px 36px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    animation: buttonGlow 3s ease-in-out infinite;
}

@keyframes buttonGlow {

    0%,
    100% {
        background-position: 0% 50%;
        box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    }

    50% {
        background-position: 100% 50%;
        box-shadow: 0 6px 24px rgba(240, 147, 251, 0.6);
    }
}

.btn-send:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.5);
}

.btn-send:active {
    transform: translateY(-1px) scale(1.02);
}

/* Brand logo magical effect */
.brand-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea, #764ba2, #f093fb, #4facfe);
    background-size: 300% 300%;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: white;
    font-size: 18px;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.5);
    animation: logoGlow 4s ease-in-out infinite;
}

@keyframes logoGlow {

    0%,
    100% {
        background-position: 0% 50%;
        box-shadow: 0 4px 16px rgba(102, 126, 234, 0.5);
    }

    50% {
        background-position: 100% 50%;
        box-shadow: 0 4px 20px rgba(240, 147, 251, 0.7);
    }
}

/* ===== TEMPLATES VIEW ===== */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin: 0 auto;
}

.template-card {
    background: var(--bg-panel, #ffffff);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.2s;
}

.template-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.template-card .icon-box {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
}

.template-card h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
}

.template-card p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

.template-card.add-new {
    border: 2px dashed var(--border-light);
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
}

/* ===== HISTORY VIEW ===== */
.history-list {
    background: var(--bg-panel, #ffffff);
    border-radius: 12px;
    border: 1px solid var(--border-light);
    overflow: hidden;
    margin: 0;
}

.history-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 16px;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item .icon-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

/* ===== SETTINGS VIEW ===== */
.settings-card {
    background: var(--bg-panel, #ffffff);
    padding: 32px;
    border-radius: 16px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    margin: 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-panel, #ffffff);
    font-size: 14px;
    font-family: inherit;
}

.settings-actions {
    margin-top: 32px;
    display: flex;
    gap: 12px;
}

.btn-alt {
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-panel, #ffffff);
    color: var(--text-main);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-alt:hover {
    background: var(--bg-app);
}

.btn-main {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-main:hover {
    background: var(--primary-hover);
}

/* ===== PROFILE VIEW ===== */
.profile-detail-card {
    background: var(--bg-panel, #ffffff);
    padding: 32px;
    border-radius: 16px;
    border: 1px solid var(--border-light);
    margin: 0 0 24px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-top: 24px;
}

.stat-box {
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== COMPOSER AREA (AI Input Section) ===== */
.composer-area {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 24px 32px 24px;
    position: relative;
    z-index: 10;
}

.input-container {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all 0.3s ease;
}

.input-container:focus-within {
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.25);
}

.main-textarea {
    border: none;
    outline: none;
    resize: none;
    width: 100%;
    min-height: 80px;
    max-height: 200px;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-main);
    background: transparent;
}

.main-textarea::placeholder {
    color: var(--text-muted);
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.config-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.config-pill {
    font-size: 12px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 20px;
    background: #F3F4F6;
    color: #6B7280;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
}

.config-pill:hover {
    background: #E5E7EB;
    color: #374151;
}

.config-pill.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.config-pill i {
    font-size: 11px;
}

.send-btn-large {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    flex-shrink: 0;
}

.send-btn-large:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.send-btn-large:active {
    transform: translateY(0) scale(1);
}

.send-btn-large i {
    font-size: 16px;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked+.slider:before {
    -webkit-transform: translateX(20px);
    -ms-transform: translateX(20px);
    transform: translateX(20px);
}

/* Rounded sliders by default */
.slider {
    border-radius: 34px;
}

.slider:before {
    border-radius: 50%;
}

/* ===== NEW TEMPLATES UI (DASHBOARD) ===== */
.templates-layout {
    display: flex;
    gap: 32px;
    height: 100%;
}

.templates-sidebar {
    width: 220px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-light);
    padding-right: 24px;
}

.sidebar-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 700;
    margin: 0 0 16px 0;
}

.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-list li {
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-list li i {
    color: var(--text-muted);
    width: 16px;
    text-align: center;
}

.category-list li:hover {
    background: var(--bg-surface-2, #f1f5f9);
}

.category-list li.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}

.category-list li.active i {
    color: var(--primary);
}

.templates-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.templates-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.templates-grid.modern {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    max-width: none;
    margin: 0;
}

.template-card.modern {
    display: flex;
    flex-direction: column;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    background: var(--bg-panel, #ffffff);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.template-card.modern:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--border-focus);
}

.tc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.tc-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--bg-surface-2, #f1f5f9);
    color: var(--text-muted);
}

.template-card.modern .icon-box {
    margin-bottom: 0;
    font-size: 20px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-card.modern .icon-box.blue {
    background: #eff6ff;
    color: #3b82f6;
}

.template-card.modern .icon-box.green {
    background: #f0fdf4;
    color: #22c55e;
}

.template-card.modern .icon-box.red {
    background: #fef2f2;
    color: #ef4444;
}

.template-card.modern h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
}

.template-card.modern p {
    flex: 1;
    margin: 0 0 20px 0;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

.template-card.modern button {
    width: 100%;
}

.btn-alt.outline {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-main);
}

.btn-alt.outline:hover {
    background: var(--bg-surface-2, #f1f5f9);
}

.template-card.modern.add-new {
    border: 2px dashed var(--border-light);
    background: transparent;
    box-shadow: none;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.template-card.modern.add-new:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #eff6ff;
}

.template-card.modern.add-new i {
    font-size: 28px;
    margin-bottom: 12px;
}

/* ===== VIEW TOGGLE BUTTONS ===== */
.view-toggle-group {
    display: flex;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: hidden;
}

.view-toggle-btn {
    background: var(--bg-surface-2, #f1f5f9);
    border: none;
    padding: 7px 12px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    transition: all 0.2s;
}

.view-toggle-btn:first-child {
    border-right: 1px solid var(--border-light);
}

.view-toggle-btn.active {
    background: var(--accent, #6366f1);
    color: white;
}

.view-toggle-btn:hover:not(.active) {
    background: var(--border-light);
}

/* ===== TEMPLATES LIST VIEW ===== */
.templates-grid.modern.list-layout {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.templates-grid.modern.list-layout .template-card.modern {
    flex-direction: row !important;
    align-items: center;
    padding: 12px 16px;
    gap: 0;
    min-height: 0;
}

/* Hide icon/tag header and cloud icon in list view */
.templates-grid.modern.list-layout .template-card.modern .tc-header,
.templates-grid.modern.list-layout .template-card.modern > i {
    display: none !important;
}

.templates-grid.modern.list-layout .template-card.modern h3 {
    margin: 0;
    white-space: nowrap;
    min-width: 130px;
    max-width: 180px;
    font-size: 13px;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.templates-grid.modern.list-layout .template-card.modern p {
    flex: 1;
    margin: 0 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block !important;
    -webkit-line-clamp: unset !important;
    -webkit-box-orient: unset !important;
    font-size: 12px;
    color: var(--text-muted);
    min-width: 0;
}

/* Edit button - compact in list view */
.templates-grid.modern.list-layout .template-card.modern button.btn-alt {
    width: auto !important;
    margin-top: 0 !important;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 5px 14px;
    font-size: 11px;
    order: 10;
}

/* Move top-right action buttons inline for list view */
.templates-grid.modern.list-layout .template-card.modern > button:first-child:not(.btn-alt) {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    margin-left: 8px;
    flex-shrink: 0;
    order: 11;
}

.templates-grid.modern.list-layout .template-card.modern.add-new {
    flex-direction: row !important;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    min-height: 0;
}

.templates-grid.modern.list-layout .template-card.modern.add-new i {
    font-size: 14px;
    margin-bottom: 0;
}

.templates-grid.modern.list-layout .template-card.modern:hover {
    transform: none;
}

/* ===== DARK MODE OVERRIDES ===== */
[data-theme="dark"] {
    /* Dashboard variables */
    --bg-app: #0f172a;
    --bg-panel: #1e293b;
    --bg-sidebar: #020617;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-light: #334155;
    --border-focus: #3b82f6;
    --bg-surface-2: #1e293b;

    /* style.css variables (used by popup-box, notes, etc.) */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --accent-color: #6366f1;
    --accent-text: #ffffff;
    --sidebar-bg: #020617;

    /* Extra dashboard-specific variables */
    --bg-card: #1e293b;
    --bg-surface-1: #1e293b;
    --bg-surface-3: #0f172a;
    --bg-input: #0f172a;
    --bg-input-focus: #1e293b;
    --text-placeholder: #64748b;
    --border-default: #334155;
    --border-subtle: #1e293b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

/* ── Core containers ── */
[data-theme="dark"] .top-bar,
[data-theme="dark"] .history-list,
[data-theme="dark"] .template-card,
[data-theme="dark"] .settings-card,
[data-theme="dark"] .profile-detail-card,
[data-theme="dark"] .stat-box {
    background: var(--bg-panel);
    border-color: var(--border-light);
    color: var(--text-main);
}

[data-theme="dark"] .search-input-wrapper {
    background: var(--bg-panel);
    border-color: var(--border-light);
}

[data-theme="dark"] .magical-textarea {
    color: var(--text-main);
}

/* ── AI composer & feature cards ── */
[data-theme="dark"] .feature-card,
[data-theme="dark"] .ai-composer {
    background: var(--bg-panel);
    border-color: var(--border-light);
    color: var(--text-main);
}

[data-theme="dark"] .config-pill {
    background: var(--border-light);
    color: var(--text-main);
}

[data-theme="dark"] .btn-alt.outline {
    border-color: var(--border-light);
    color: var(--text-main);
}

/* ── Template cards ── */
[data-theme="dark"] .template-card.modern {
    background: var(--bg-panel);
    border-color: var(--border-light);
    color: var(--text-main);
}

[data-theme="dark"] .template-card.modern h3 {
    color: var(--text-main);
}

[data-theme="dark"] .template-card.modern p {
    color: var(--text-muted);
}

[data-theme="dark"] .template-card.modern button {
    background: var(--bg-panel);
    border-color: var(--border-light);
    color: var(--text-main);
}

[data-theme="dark"] .template-card.modern.add-new {
    background: transparent;
    border-color: var(--border-light);
}

[data-theme="dark"] .template-card.modern.add-new:hover {
    background: rgba(59, 130, 246, 0.1);
}

[data-theme="dark"] .tc-tag {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

[data-theme="dark"] .templates-grid {
    background: var(--bg-panel) !important;
    border-color: var(--border-light) !important;
}

/* ── Template search bar ── */
[data-theme="dark"] #templateSearchInput {
    background: var(--bg-app) !important;
    border-color: var(--border-light) !important;
    color: var(--text-main) !important;
}

/* ── Template modal (Create/Edit) ── */
[data-theme="dark"] #createTemplateModal > div {
    background: var(--bg-panel) !important;
}

[data-theme="dark"] #createTemplateModal h3 {
    color: var(--text-main) !important;
}

[data-theme="dark"] #createTemplateModal input,
[data-theme="dark"] #createTemplateModal textarea,
[data-theme="dark"] #createTemplateModal select {
    background: var(--bg-app) !important;
    border-color: var(--border-light) !important;
    color: var(--text-main) !important;
}

/* ── Notes search bar (dashboard) ── */
[data-theme="dark"] #searchInput {
    background: var(--bg-app) !important;
    border-color: var(--border-light) !important;
    color: var(--text-main) !important;
}

/* ── Category sidebar hover ── */
[data-theme="dark"] .templates-sidebar {
    background: var(--bg-panel);
}

/* ── Popup / Note editor ── */
[data-theme="dark"] .popup-box {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    color: var(--text-main);
}

[data-theme="dark"] .popup-header {
    border-color: var(--border-light);
    color: var(--text-main);
}

[data-theme="dark"] .popup-header .close-icon {
    color: var(--text-muted);
}

[data-theme="dark"] .popup-content label {
    color: var(--text-main);
}

[data-theme="dark"] .popup-footer {
    border-color: var(--border-light);
}

/* ── Note cards ── */
[data-theme="dark"] .note-card,
[data-theme="dark"] .note {
    background: var(--bg-panel);
    border-top-color: var(--border-light);
    border-bottom-color: var(--border-light);
    color: var(--text-main);
}

/* Preserve color bar on left/right borders in dark mode */
[data-theme="dark"] .note.white { border-left-color: #cbd5e1; border-right-color: #cbd5e1; }
[data-theme="dark"] .note.blue { border-left-color: #3b82f6; border-right-color: #3b82f6; }
[data-theme="dark"] .note.purple { border-left-color: #8b5cf6; border-right-color: #8b5cf6; }
[data-theme="dark"] .note.yellow { border-left-color: #eab308; border-right-color: #eab308; }
[data-theme="dark"] .note.green { border-left-color: #22c55e; border-right-color: #22c55e; }
[data-theme="dark"] .note.red { border-left-color: #ef4444; border-right-color: #ef4444; }

[data-theme="dark"] .note-card h4,
[data-theme="dark"] .note h4 {
    color: var(--text-main);
}

[data-theme="dark"] .note-card p,
[data-theme="dark"] .note p {
    color: var(--text-muted);
}

/* ── Settings sections ── */
[data-theme="dark"] .setting-row {
    border-color: var(--border-light);
}

[data-theme="dark"] .setting-label {
    color: var(--text-main);
}

[data-theme="dark"] .setting-desc {
    color: var(--text-muted);
}

[data-theme="dark"] .setting-select,
[data-theme="dark"] .setting-number-input {
    background: var(--bg-app);
    border-color: var(--border-light);
    color: var(--text-main);
}

[data-theme="dark"] .settings-section-title {
    color: var(--text-muted);
}

/* ── View toggle buttons ── */
[data-theme="dark"] .view-toggle-btn {
    background: var(--bg-panel);
    color: var(--text-muted);
}

[data-theme="dark"] .view-toggle-btn.active {
    background: var(--accent, #6366f1);
    color: white;
}

/* ── Buttons ── */
[data-theme="dark"] #themeToggleBtn {
    background: var(--bg-panel);
    border-color: var(--border-light);
    color: var(--text-main);
}

[data-theme="dark"] .btn-alt {
    background: var(--bg-panel);
    border-color: var(--border-light);
    color: var(--text-main);
}

/* ── History list items ── */
[data-theme="dark"] .history-item {
    border-color: var(--border-light);
    color: var(--text-main);
}

[data-theme="dark"] .history-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* ── Category sidebar ── */
[data-theme="dark"] .category-item {
    color: var(--text-muted);
}

[data-theme="dark"] .category-item.active,
[data-theme="dark"] .category-item:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent, #6366f1);
}

/* ── Category filter chips & picker (dark) ── */
[data-theme="dark"] .category-chip {
    background: var(--bg-panel, #1e293b);
    color: var(--text-muted, #94a3b8);
    border-color: var(--border-light, #334155);
}
[data-theme="dark"] .category-chip:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--text-main, #e2e8f0);
}
[data-theme="dark"] .category-chip.active {
    background: var(--accent, #6366f1);
    color: #fff;
    border-color: var(--accent, #6366f1);
}
[data-theme="dark"] .add-category-chip {
    color: var(--accent, #6366f1);
    background: transparent;
}
[data-theme="dark"] .add-category-chip:hover {
    background: var(--accent, #6366f1);
    color: #fff;
}
[data-theme="dark"] .note-category-badge {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-muted, #94a3b8);
    border: 1px solid rgba(99, 102, 241, 0.2);
}
[data-theme="dark"] .category-picker select {
    background: var(--bg-panel, #1e293b);
    color: var(--text-main, #e2e8f0);
    border-color: var(--border-light, #334155);
}

/* ── Quill editor ── */
[data-theme="dark"] .ql-toolbar {
    background: var(--bg-app);
    border-color: var(--border-light) !important;
}

[data-theme="dark"] .ql-toolbar .ql-stroke {
    stroke: var(--text-muted) !important;
}

[data-theme="dark"] .ql-toolbar .ql-fill {
    fill: var(--text-muted) !important;
}

[data-theme="dark"] .ql-toolbar .ql-picker-label {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .ql-container {
    border-color: var(--border-light) !important;
    color: var(--text-main);
}

[data-theme="dark"] .ql-editor {
    background: var(--bg-panel);
    color: var(--text-main);
}

[data-theme="dark"] .ql-editor.ql-blank::before {
    color: var(--text-muted);
}

/* ── Misc overlays and modals ── */
[data-theme="dark"] .overlay-backdrop {
    background: rgba(0, 0, 0, 0.7);
}

/* ── Color dots (note colors) ── */
[data-theme="dark"] .color-dot {
    border-color: var(--border-light);
}

/* ── Scrollbar ── */
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--bg-app);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--border-light);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #475569;
}