/* ================================================================
   PlanMate AI — Main Stylesheet  v2.0.0
   Design: Premium dark-mode, glassmorphism, responsive, RTL-ready
   ================================================================ */

/* ── 1. Custom Properties ─────────────────────────────────────── */
:root {
    --pm-primary:       #3B82F6;
    --pm-primary-dark:  #2563EB;
    --pm-primary-light: #60A5FA;
    --pm-primary-glow:  rgba(59, 130, 246, 0.35);
    --pm-ai:            #8B5CF6;
    --pm-ai-dark:       #7C3AED;
    --pm-ai-light:      rgba(139, 92, 246, 0.15);
    --pm-ai-glow:       rgba(139, 92, 246, 0.35);

    --pm-success:       #22C55E;
    --pm-success-glow:  rgba(34, 197, 94, 0.2);
    --pm-warning:       #F59E0B;
    --pm-warning-glow:  rgba(245, 158, 11, 0.2);
    --pm-danger:        #EF4444;
    --pm-danger-glow:   rgba(239, 68, 68, 0.2);
    --pm-info:          #06B6D4;

    --pm-bg:            #0B0F1A;
    --pm-bg-secondary:  #0F1629;
    --pm-surface:       rgba(17, 24, 42, 0.65);
    --pm-surface-solid: #111828;
    --pm-surface-hover: rgba(23, 32, 55, 0.75);
    --pm-border:        rgba(255, 255, 255, 0.06);
    --pm-border-soft:   rgba(255, 255, 255, 0.03);
    --pm-border-glow:   rgba(255, 255, 255, 0.1);

    --pm-text:          #E2E8F0;
    --pm-text-muted:    #94A3B8;
    --pm-text-light:    #64748B;

    /* Stat card accent colours */
    --pm-stat-total:      #3B82F6;
    --pm-stat-pending:    #F59E0B;
    --pm-stat-inprogress: #06B6D4;
    --pm-stat-completed:  #22C55E;
    --pm-stat-today:      #8B5CF6;
    --pm-stat-overdue:    #EF4444;

    --pm-radius:        12px;
    --pm-radius-lg:     18px;
    --pm-radius-sm:     8px;
    --pm-shadow:        0 2px 8px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
    --pm-shadow-md:     0 4px 20px rgba(0, 0, 0, 0.4);
    --pm-shadow-lg:     0 12px 40px rgba(0, 0, 0, 0.5);
    --pm-shadow-glow:   0 0 20px rgba(59, 130, 246, 0.15);

    --pm-glass-blur:    blur(16px);
    --pm-glass-blur-sm: blur(8px);
    --pm-transition:    .25s cubic-bezier(.4, 0, .2, 1);
    --pm-transition-slow: .4s cubic-bezier(.4, 0, .2, 1);
}

/* ── 2. Keyframe Animations ───────────────────────────────────── */
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 4px var(--pm-primary), 0 0 8px var(--pm-primary-glow); opacity: 1; }
    50%      { box-shadow: 0 0 8px var(--pm-primary), 0 0 20px var(--pm-primary-glow); opacity: .8; }
}

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

@keyframes floatSlow {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(30px, -20px) scale(1.05); }
    66%      { transform: translate(-20px, 10px) scale(.97); }
}

@keyframes shimmer {
    0%   { background-position: -200% center; }
    100% { background-position: 200% center; }
}

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

/* Phase 4: Calendar & time blocking */
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.calendar-day { min-height: 120px; background: var(--pm-surface); border: 1px solid var(--pm-border); border-radius: var(--pm-radius); padding: .6rem; }
.calendar-day-num { font-weight: 700; color: var(--pm-text-muted); margin-bottom: .4rem; }
.calendar-event { display: block; border-inline-start: 3px solid var(--event-color, var(--pm-primary)); background: rgba(74,127,229,.08); color: var(--pm-text); border-radius: 6px; padding: .25rem .4rem; font-size: .78rem; margin-bottom: .25rem; }
.time-block-review { display: flex; align-items: flex-start; gap: .65rem; border: 1px solid var(--pm-border); border-radius: 10px; padding: .8rem; margin-bottom: .6rem; }
.time-block-review span { display: flex; flex-direction: column; gap: .15rem; }
.time-block-review small, .time-block-review em { color: var(--pm-text-muted); font-size: .85rem; }
.markdown-table-wrap { overflow-x: auto; margin: 1rem 0; }
.markdown-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.markdown-table th, .markdown-table td { border: 1px solid var(--pm-border); padding: .65rem .75rem; vertical-align: top; }
.markdown-table th { background: rgba(74,127,229,.08); color: var(--pm-text); font-weight: 700; }
.markdown-table tr:nth-child(even) td { background: rgba(148,163,184,.06); }
.markdown-table .schedule-gap-row td { background: rgba(245, 158, 11, .12); color: #fbbf24; }
.markdown-table .schedule-existing-row td { background: rgba(2, 132, 199, .10); }
@media (max-width: 767.98px) { .calendar-grid { grid-template-columns: 1fr; } .calendar-day { min-height: auto; } }

@keyframes borderGlow {
    0%, 100% { border-color: rgba(59, 130, 246, 0.2); }
    50%      { border-color: rgba(59, 130, 246, 0.5); }
}

@keyframes rippleExpand {
    to { transform: scale(4); opacity: 0; }
}

@keyframes orbFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25%      { transform: translate(60px, -40px) scale(1.1); }
    50%      { transform: translate(-30px, 50px) scale(.95); }
    75%      { transform: translate(40px, 20px) scale(1.05); }
}

@keyframes orbFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25%      { transform: translate(-50px, 30px) scale(1.08); }
    50%      { transform: translate(40px, -60px) scale(.92); }
    75%      { transform: translate(-20px, -30px) scale(1.03); }
}

@keyframes orbFloat3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    30%      { transform: translate(20px, 40px) scale(1.06); }
    60%      { transform: translate(-40px, -20px) scale(.96); }
}

/* ── 3. Ambient Background ────────────────────────────────────── */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.ambient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: .25;
}

.ambient-orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #3B82F6 0%, transparent 70%);
    top: -10%;
    left: -5%;
    animation: orbFloat1 25s ease-in-out infinite;
}

.ambient-orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #8B5CF6 0%, transparent 70%);
    top: 50%;
    right: -8%;
    animation: orbFloat2 30s ease-in-out infinite;
}

.ambient-orb-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #06B6D4 0%, transparent 70%);
    bottom: -5%;
    left: 30%;
    animation: orbFloat3 20s ease-in-out infinite;
}

/* ── 4. Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    color: var(--pm-text);
    background: var(--pm-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.rtl-body {
    font-family: 'Cairo', system-ui, Arial, sans-serif;
}

a { color: var(--pm-primary-light); text-decoration: none; transition: color var(--pm-transition); }
a:hover { color: #93C5FD; }

/* ── 5. Typography ────────────────────────────────────────────── */
.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--pm-text);
    margin: 0;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--pm-text-muted);
    margin: .25rem 0 0;
    font-size: .9rem;
}

.section-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--pm-text);
    letter-spacing: -0.02em;
}

/* ── 6. Navbar ────────────────────────────────────────────────── */
.app-navbar {
    background: rgba(11, 15, 26, 0.75);
    backdrop-filter: var(--pm-glass-blur);
    -webkit-backdrop-filter: var(--pm-glass-blur);
    border-bottom: 1px solid var(--pm-border);
    padding-top: .65rem;
    padding-bottom: .65rem;
    transition: background var(--pm-transition), box-shadow var(--pm-transition);
    z-index: 1030;
}

.app-navbar.navbar-scrolled {
    background: rgba(11, 15, 26, 0.92);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.app-brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--pm-text) !important;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.app-navbar .navbar-nav {
    flex-wrap: nowrap;
}

.brand-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--pm-primary);
    flex-shrink: 0;
    animation: pulseGlow 2.5s ease-in-out infinite;
}

.app-navbar .nav-link {
    color: var(--pm-text-muted);
    font-weight: 500;
    padding: .4rem .55rem;
    border-radius: var(--pm-radius-sm);
    transition: color var(--pm-transition), background var(--pm-transition);
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    white-space: nowrap;
}

@media (min-width: 992px) and (max-width: 1199.98px) {
    .app-navbar .nav-link { font-size: .88rem; padding-inline: .42rem; }
    .app-navbar .nav-link .bi { margin-inline-end: .15rem !important; }
    .app-brand { font-size: 1.05rem; }
}

.app-navbar .nav-link:hover {
    color: var(--pm-text);
    background: rgba(255, 255, 255, 0.05);
}

.app-navbar .nav-link.active {
    color: var(--pm-primary-light);
    background: rgba(59, 130, 246, 0.1);
}

.app-navbar .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: var(--pm-primary);
    border-radius: 1px;
    box-shadow: 0 0 8px var(--pm-primary-glow);
}

.user-nav-link {
    display: flex;
    align-items: center;
    gap: .45rem;
}

.user-avatar-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pm-primary) 0%, var(--pm-ai) 100%);
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 0 12px var(--pm-primary-glow);
}

/* Navbar toggler (hamburger) for mobile */
.navbar-toggler {
    padding: .4rem .55rem;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: var(--pm-radius-sm);
    background: rgba(255, 255, 255, 0.05);
    transition: all var(--pm-transition);
}

.navbar-toggler:hover,
.navbar-toggler:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.15);
}

.navbar-toggler-icon,
[data-bs-theme="dark"] .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23ffffff' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2.5' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
    width: 1.3em;
    height: 1.3em;
    filter: none !important;
    opacity: 1 !important;
}

/* Mobile expanded menu glass backdrop */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background: rgba(11, 15, 26, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid var(--pm-border);
        border-radius: var(--pm-radius);
        margin-top: .75rem;
        padding: 1rem;
        box-shadow: var(--pm-shadow-lg);
    }

    .navbar-collapse .navbar-nav {
        gap: .15rem;
    }

    .navbar-collapse .nav-link {
        padding: .6rem .85rem !important;
        border-radius: var(--pm-radius-sm) !important;
        font-size: .92rem;
    }

    .navbar-collapse .nav-link:hover {
        background: rgba(255, 255, 255, 0.06);
    }

    .navbar-collapse .nav-link.active::after {
        display: none;
    }

    .navbar-collapse .nav-link.active {
        background: rgba(59, 130, 246, 0.12);
        border-left: 3px solid var(--pm-primary);
    }

    [dir="rtl"] .navbar-collapse .nav-link.active {
        border-left: none;
        border-right: 3px solid var(--pm-primary);
    }

    .navbar-collapse .lang-switcher {
        margin: .5rem 0;
    }

    .navbar-collapse .user-nav-link {
        padding: .6rem .85rem !important;
    }

    .navbar-collapse .dropdown-menu {
        border: none;
        background: rgba(255, 255, 255, 0.04);
        box-shadow: none;
        margin-top: .25rem;
    }
}

/* ── 7. Language Switcher ─────────────────────────────────────── */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: .25rem .5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--pm-border);
}

.lang-btn {
    font-size: .78rem;
    font-weight: 600;
    color: var(--pm-text-muted);
    padding: 3px 8px;
    border-radius: 999px;
    transition: all var(--pm-transition);
}

.lang-btn:hover { color: var(--pm-text); }

.lang-btn.active {
    color: var(--pm-primary-light);
    background: rgba(59, 130, 246, 0.15);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.1);
}

.lang-divider { color: var(--pm-text-light); font-size: .7rem; opacity: .4; }

/* ── 8. Buttons ───────────────────────────────────────────────── */
.btn {
    border-radius: var(--pm-radius-sm);
    font-weight: 500;
    transition: all var(--pm-transition);
    position: relative;
    overflow: hidden;
}

.btn-ripple {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: rippleExpand .6s ease-out;
    pointer-events: none;
}

.btn-primary {
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, #60A5FA 0%, #3B82F6 100%);
    border-color: rgba(96, 165, 250, 0.4);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
    color: #fff;
}

.btn-outline-primary {
    color: var(--pm-primary-light);
    border-color: rgba(59, 130, 246, 0.3);
    background: transparent;
}

.btn-outline-primary:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.5);
    color: var(--pm-primary-light);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}

.btn-outline-secondary {
    color: var(--pm-text-muted);
    border-color: var(--pm-border-glow);
    background: transparent;
}

.btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--pm-text);
}

.btn-ai {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.1));
    color: #A78BFA;
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: var(--pm-radius-sm);
    font-weight: 600;
    transition: all var(--pm-transition);
}

.btn-ai:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(139, 92, 246, 0.15));
    color: #C4B5FD;
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 4px 20px var(--pm-ai-glow);
    transform: translateY(-1px);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--pm-radius-sm);
    border: none;
    background: transparent;
    color: var(--pm-text-muted);
    cursor: pointer;
    transition: all var(--pm-transition);
    padding: 0;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--pm-text);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.05);
}

.btn-icon.text-danger:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #F87171;
    box-shadow: 0 0 10px var(--pm-danger-glow);
}

.btn-success {
    background: linear-gradient(135deg, #22C55E 0%, #16A34A 100%);
    border-color: rgba(34, 197, 94, 0.3);
}

.btn-success:hover {
    box-shadow: 0 4px 20px var(--pm-success-glow);
}

/* ── 9. Cards ─────────────────────────────────────────────────── */
.app-card {
    background: var(--pm-surface);
    backdrop-filter: var(--pm-glass-blur-sm);
    -webkit-backdrop-filter: var(--pm-glass-blur-sm);
    border: 1px solid var(--pm-border);
    border-radius: var(--pm-radius);
    box-shadow: var(--pm-shadow);
    transition: border-color var(--pm-transition), box-shadow var(--pm-transition);
}

.app-card:hover {
    border-color: var(--pm-border-glow);
}

.app-card .card-header {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--pm-border);
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--pm-text);
}

.card-body {
    color: var(--pm-text);
}

/* ── 10. Stat Cards ───────────────────────────────────────────── */
.stat-card {
    background: var(--pm-surface);
    backdrop-filter: var(--pm-glass-blur-sm);
    -webkit-backdrop-filter: var(--pm-glass-blur-sm);
    border: 1px solid var(--pm-border);
    border-radius: var(--pm-radius);
    padding: 1.15rem 1rem;
    text-align: center;
    box-shadow: var(--pm-shadow);
    transition: all var(--pm-transition);
    height: 100%;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--stat-accent, var(--pm-primary)) 50%, transparent 100%);
    opacity: .6;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--pm-shadow-md), 0 0 20px var(--stat-glow, var(--pm-primary-glow));
    border-color: rgba(255, 255, 255, 0.08);
}

.stat-icon { font-size: 1.5rem; margin-bottom: .45rem; line-height: 1; }

.stat-num {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--pm-text-muted);
    margin-top: .35rem;
}

/* Stat colour variants */
.stat-total     { --stat-accent: var(--pm-stat-total);      --stat-glow: rgba(59,130,246,.2); }
.stat-pending   { --stat-accent: var(--pm-stat-pending);    --stat-glow: rgba(245,158,11,.2); }
.stat-inprogress{ --stat-accent: var(--pm-stat-inprogress); --stat-glow: rgba(6,182,212,.2); }
.stat-completed { --stat-accent: var(--pm-stat-completed);  --stat-glow: rgba(34,197,94,.2); }
.stat-today     { --stat-accent: var(--pm-stat-today);      --stat-glow: rgba(139,92,246,.2); }
.stat-overdue   { --stat-accent: var(--pm-stat-overdue);    --stat-glow: rgba(239,68,68,.2); }

.stat-total     .stat-icon, .stat-total     .stat-num { color: var(--pm-stat-total); }
.stat-pending   .stat-icon, .stat-pending   .stat-num { color: var(--pm-stat-pending); }
.stat-inprogress .stat-icon, .stat-inprogress .stat-num { color: var(--pm-stat-inprogress); }
.stat-completed .stat-icon, .stat-completed .stat-num { color: var(--pm-stat-completed); }
.stat-today     .stat-icon, .stat-today     .stat-num { color: var(--pm-stat-today); }
.stat-overdue   .stat-icon, .stat-overdue   .stat-num { color: var(--pm-stat-overdue); }

/* ── 11. Badges ───────────────────────────────────────────────── */
.badge {
    font-weight: 600;
    font-size: .72rem;
    padding: .3em .65em;
    border-radius: 999px;
}

/* Priority badges */
.badge-priority-high   { background: rgba(239, 68, 68, 0.15); color: #F87171; border: 1px solid rgba(239,68,68,.2); }
.badge-priority-medium { background: rgba(245, 158, 11, 0.15); color: #FBBF24; border: 1px solid rgba(245,158,11,.2); }
.badge-priority-low    { background: rgba(34, 197, 94, 0.15); color: #4ADE80; border: 1px solid rgba(34,197,94,.2); }

/* Status badges */
.badge-status-completed  { background: rgba(34, 197, 94, 0.15); color: #4ADE80; }
.badge-status-inprogress { background: rgba(59, 130, 246, 0.15); color: #60A5FA; }
.badge-status-pending    { background: rgba(148, 163, 184, 0.12); color: #94A3B8; }

/* Overdue badge */
.badge-overdue {
    background: rgba(239, 68, 68, 0.18);
    color: #FCA5A5;
    font-size: .65rem;
    vertical-align: middle;
    animation: pulseGlow 3s ease-in-out infinite;
    --pm-primary: var(--pm-danger);
    --pm-primary-glow: var(--pm-danger-glow);
}

.badge-subtask {
    background: rgba(6, 182, 212, 0.15);
    color: #67E8F9;
    font-size: .65rem;
    vertical-align: middle;
}

.badge-ai-generated {
    background: var(--pm-ai-light);
    color: #A78BFA;
    font-size: .65rem;
    vertical-align: middle;
}

.task-parent-link {
    color: var(--pm-text-muted);
    font-size: .78rem;
}

.subtask-toggle {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    border: 1px solid var(--pm-border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--pm-text);
    border-radius: 999px;
    padding: .3rem .7rem;
    font-size: .78rem;
    font-weight: 600;
    transition: all var(--pm-transition);
    cursor: pointer;
}

.subtask-toggle:hover {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.2);
    color: var(--pm-primary-light);
}

.subtask-progress-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--pm-text-light);
    flex-shrink: 0;
}

.subtask-progress-dot.partial { background: var(--pm-warning); box-shadow: 0 0 6px var(--pm-warning-glow); }
.subtask-progress-dot.complete { background: var(--pm-success); box-shadow: 0 0 6px var(--pm-success-glow); }

.subtask-progress-mini {
    width: 54px;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    display: inline-flex;
}

.subtask-progress-mini span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #8B5CF6, #22C55E);
}

.subtask-progress-percent {
    color: var(--pm-text-muted);
    font-size: .72rem;
}

.subtask-ready-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    background: rgba(34, 197, 94, 0.08);
    color: #4ADE80;
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: var(--pm-radius);
    padding: .75rem .9rem;
}

.subtask-refine-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: var(--pm-radius);
    padding: .75rem .9rem;
}

.project-card,
.project-hero {
    border-top: 3px solid var(--project-color, var(--pm-primary));
}

.project-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--project-color, var(--pm-primary)) 15%, transparent);
    color: var(--project-color, var(--pm-primary));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.project-progress { height: 7px; border-radius: 999px; background: rgba(255,255,255,.08); }
.project-progress-lg { height: 10px; border-radius: 999px; background: rgba(255,255,255,.08); }

.org-chip,
.tag-pill,
.tag-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    padding: .25rem .6rem;
    background: color-mix(in srgb, var(--chip-color, var(--tag-color, var(--pm-primary))) 12%, transparent);
    color: var(--chip-color, var(--tag-color, var(--pm-primary)));
    border: 1px solid color-mix(in srgb, var(--chip-color, var(--tag-color, var(--pm-primary))) 20%, transparent);
}

.tag-chip { border: none; cursor: pointer; }
.task-org-row { display: flex; flex-wrap: wrap; gap: .35rem; }

.tag-selector {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
}

.tag-check input { display: none; }
.tag-check span {
    display: inline-flex;
    border-radius: 999px;
    padding: .28rem .65rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--tag-color);
    border: 1px solid color-mix(in srgb, var(--tag-color) 25%, transparent);
    background: transparent;
    cursor: pointer;
    transition: all var(--pm-transition);
}
.tag-check input:checked + span {
    background: color-mix(in srgb, var(--tag-color) 15%, transparent);
    box-shadow: 0 0 8px color-mix(in srgb, var(--tag-color) 20%, transparent);
}

.project-mini-card {
    display: block;
    border: 1px solid var(--pm-border);
    border-radius: var(--pm-radius);
    padding: .9rem;
    background: var(--pm-surface);
    backdrop-filter: var(--pm-glass-blur-sm);
    transition: all var(--pm-transition);
}

.project-mini-card:hover {
    border-color: var(--pm-border-glow);
    box-shadow: var(--pm-shadow-md);
    transform: translateY(-2px);
}

.subtask-nest {
    border-inline-start: 2px solid rgba(139, 92, 246, 0.25);
    margin-inline-start: 2.25rem;
    padding-inline-start: 1rem;
}

.subtask-row {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .8rem 0;
    border-top: 1px solid var(--pm-border-soft);
}

.subtask-content {
    flex: 1;
    min-width: 0;
}

.subtask-title {
    font-weight: 600;
    color: var(--pm-text);
    line-height: 1.45;
}

.subtask-title.completed {
    text-decoration: line-through;
    color: var(--pm-text-muted);
}

.subtask-desc {
    color: var(--pm-text-muted);
    font-size: .84rem;
    line-height: 1.55;
    margin-top: .15rem;
}

/* ── 12. Task List (dashboard & tasks page) ───────────────────── */
.task-list { }

.task-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .8rem 1.25rem;
    border-bottom: 1px solid var(--pm-border-soft);
    gap: .75rem;
    transition: all var(--pm-transition);
}

.task-row:last-child { border-bottom: none; }

.task-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.task-row-left  { display: flex; align-items: center; gap: .75rem; flex: 1; min-width: 0; }
.task-row-right { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }

.task-info { min-width: 0; }

.task-title {
    font-weight: 500;
    color: var(--pm-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.task-title.completed {
    text-decoration: line-through;
    color: var(--pm-text-muted);
}

.task-due {
    font-size: .78rem;
    color: var(--pm-text-muted);
}

/* Task check button (toggle complete) */
.task-check-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 1.15rem;
    color: var(--pm-text-light);
    line-height: 1;
    transition: all var(--pm-transition);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.task-check-btn:hover { color: var(--pm-primary-light); text-shadow: 0 0 8px var(--pm-primary-glow); }
.task-check-btn.checked { color: var(--pm-success); text-shadow: 0 0 8px var(--pm-success-glow); }

.task-badge {
    font-size: .68rem !important;
    padding: .25em .55em !important;
}

/* ── 13. Task Cards (tasks.php) ───────────────────────────────── */
.task-cards { display: flex; flex-direction: column; gap: .6rem; }

.task-card {
    background: var(--pm-surface);
    backdrop-filter: var(--pm-glass-blur-sm);
    -webkit-backdrop-filter: var(--pm-glass-blur-sm);
    border: 1px solid var(--pm-border);
    border-radius: var(--pm-radius);
    box-shadow: var(--pm-shadow);
    transition: all var(--pm-transition);
    overflow: hidden;
}

.task-card:hover {
    border-color: var(--pm-border-glow);
    box-shadow: var(--pm-shadow-md);
    transform: translateY(-2px);
}

.task-card.task-overdue {
    border-left: 3px solid var(--pm-danger);
    box-shadow: var(--pm-shadow), -4px 0 12px var(--pm-danger-glow);
}
[dir="rtl"] .task-card.task-overdue {
    border-left: none;
    border-right: 3px solid var(--pm-danger);
    box-shadow: var(--pm-shadow), 4px 0 12px var(--pm-danger-glow);
}

.task-card.task-done { opacity: .55; }

.task-card-body { padding: .95rem 1.1rem; }

.task-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
}

.task-card-title {
    font-size: .95rem;
    font-weight: 600;
    color: var(--pm-text);
    margin-bottom: .15rem;
    line-height: 1.4;
}

.task-card-title.completed {
    text-decoration: line-through;
    color: var(--pm-text-muted);
}

.task-card-desc {
    font-size: .84rem;
    color: var(--pm-text-muted);
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.task-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
}

.task-actions {
    display: flex;
    gap: .25rem;
    flex-shrink: 0;
}

.task-meta-item {
    font-size: .78rem;
    color: var(--pm-text-muted);
    display: inline-flex;
    align-items: center;
}

/* ── 14. Auth Pages ───────────────────────────────────────────── */
.auth-page {
    display: flex;
    align-items: center;
    min-height: calc(100vh - 62px - 70px);
    padding: 2.5rem 0;
    position: relative;
}

.auth-card {
    background: var(--pm-surface);
    backdrop-filter: var(--pm-glass-blur);
    -webkit-backdrop-filter: var(--pm-glass-blur);
    border: 1px solid var(--pm-border-glow);
    border-radius: var(--pm-radius-lg);
    box-shadow: var(--pm-shadow-lg), 0 0 60px rgba(59, 130, 246, 0.06);
    padding: 2rem 2.25rem 2.25rem;
    animation: fadeInUp .5s ease-out;
}

.auth-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.app-brand-sm {
    font-size: 1rem;
    font-weight: 700;
    color: var(--pm-text) !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: .25rem;
    color: var(--pm-text);
}

.auth-subtitle {
    text-align: center;
    color: var(--pm-text-muted);
    font-size: .9rem;
    margin-bottom: 1.5rem;
}

.auth-footer-text {
    text-align: center;
    margin-top: 1.25rem;
    font-size: .88rem;
    color: var(--pm-text-muted);
}

.btn-login { padding: .6rem 1rem; font-size: .95rem; }

/* ── 15. Hero Section ─────────────────────────────────────────── */
.hero-section {
    background: linear-gradient(145deg, #0B0F1A 0%, #111828 40%, #1a1040 100%);
    padding: 5rem 0 4rem;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.12) 0%, transparent 70%);
    border-radius: 50%;
    animation: floatSlow 20s ease-in-out infinite;
    pointer-events: none;
}

.min-vh-section { min-height: auto; }

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: rgba(59, 130, 246, 0.1);
    color: var(--pm-primary-light);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 999px;
    padding: .35rem .9rem;
    font-size: .8rem;
    font-weight: 600;
}

.badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--pm-primary);
    flex-shrink: 0;
    display: inline-block;
    animation: pulseGlow 2s infinite;
}

.hero-title {
    font-size: 2.6rem;
    font-weight: 700;
    line-height: 1.2;
    margin: .85rem 0 1rem;
    color: var(--pm-text);
    letter-spacing: -0.03em;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--pm-text-muted);
    line-height: 1.65;
    margin-bottom: 1.75rem;
    max-width: 480px;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; }

/* Hero mock preview */
.hero-illustration {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.hero-card-preview {
    background: var(--pm-surface);
    backdrop-filter: var(--pm-glass-blur);
    border: 1px solid var(--pm-border-glow);
    border-radius: var(--pm-radius-lg);
    padding: 1.5rem;
    width: 360px;
    max-width: 100%;
    box-shadow: var(--pm-shadow-lg), 0 0 40px rgba(59, 130, 246, 0.08);
    animation: float 6s ease-in-out infinite;
}

.preview-header {
    display: flex;
    gap: 6px;
    margin-bottom: 1.1rem;
}

.preview-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
}

.preview-dot.red    { background: #FF5F57; }
.preview-dot.yellow { background: #FEBC2E; }
.preview-dot.green  { background: #28C840; }

.preview-stat-row {
    display: flex;
    gap: .75rem;
    margin-bottom: 1.1rem;
}

.preview-stat {
    flex: 1;
    border-radius: var(--pm-radius);
    padding: .65rem .5rem;
    text-align: center;
}

.preview-stat.blue   { background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59,130,246,.15); }
.preview-stat.green  { background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34,197,94,.15); }
.preview-stat.orange { background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245,158,11,.15); }

.preview-stat-num  { font-weight: 700; font-size: 1.35rem; line-height: 1; }
.preview-stat.blue   .preview-stat-num { color: #60A5FA; }
.preview-stat.green  .preview-stat-num { color: #4ADE80; }
.preview-stat.orange .preview-stat-num { color: #FBBF24; }

.preview-stat-label { font-size: .6rem; color: var(--pm-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-top: .2rem; }

.preview-task-list { display: flex; flex-direction: column; gap: .6rem; }

.preview-task {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .8rem;
    color: var(--pm-text);
}

.preview-task.done { color: var(--pm-text-light); text-decoration: line-through; }
.preview-task.active { font-weight: 600; }

.preview-check { color: #4ADE80; font-size: .9rem; }

.preview-circle {
    width: 14px;
    height: 14px;
    border: 2px solid var(--pm-text-light);
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── 16. Features Section ─────────────────────────────────────── */
.features-section {
    padding: 5rem 0;
    background: var(--pm-bg-secondary);
    position: relative;
}

.section-header { }

.feature-card {
    background: var(--pm-surface);
    backdrop-filter: var(--pm-glass-blur-sm);
    border: 1px solid var(--pm-border);
    border-radius: var(--pm-radius-lg);
    padding: 1.75rem 1.5rem;
    height: 100%;
    transition: all var(--pm-transition);
}

.feature-card:hover {
    border-color: var(--pm-border-glow);
    box-shadow: var(--pm-shadow-md);
    transform: translateY(-4px);
}

.feature-card.ai-feature { position: relative; overflow: hidden; }

.feature-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 1.1rem;
}

.feature-icon.blue   { background: rgba(59, 130, 246, 0.12); color: #60A5FA; }
.feature-icon.green  { background: rgba(34, 197, 94, 0.12); color: #4ADE80; }
.feature-icon.purple { background: rgba(139, 92, 246, 0.12); color: #A78BFA; }

.feature-title { font-size: 1.05rem; font-weight: 700; margin-bottom: .5rem; color: var(--pm-text); }
.feature-desc  { font-size: .88rem; color: var(--pm-text-muted); line-height: 1.6; margin: 0; }

.coming-soon-badge {
    display: inline-block;
    margin-top: .85rem;
    background: var(--pm-ai-light);
    color: #A78BFA;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    padding: .25em .75em;
    letter-spacing: .04em;
}

/* ── 16b. User Guide Section ──────────────────────────────────── */
.guide-section {
    padding: 4.5rem 0;
    background: var(--pm-bg);
    position: relative;
}

.guide-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--pm-border-glow) 50%, transparent 100%);
}

.section-subtitle {
    font-size: .95rem;
    margin-top: .4rem;
    color: var(--pm-text-muted);
}

.guide-card {
    background: var(--pm-surface);
    backdrop-filter: var(--pm-glass-blur-sm);
    -webkit-backdrop-filter: var(--pm-glass-blur-sm);
    border: 1px solid var(--pm-border);
    border-radius: var(--pm-radius);
    padding: 1.25rem 1.15rem 1.3rem;
    height: 100%;
    transition: all var(--pm-transition);
    position: relative;
    overflow: hidden;
}

/* Accent top border using the icon color */
.guide-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--gi-color, var(--pm-primary)) 50%, transparent 100%);
    opacity: .5;
}

.guide-card:hover {
    border-color: var(--pm-border-glow);
    box-shadow: var(--pm-shadow-md), 0 0 20px color-mix(in srgb, var(--gi-color, var(--pm-primary)) 12%, transparent);
    transform: translateY(-3px);
}

@supports not (background: color-mix(in srgb, red 10%, white)) {
    .guide-card:hover {
        box-shadow: var(--pm-shadow-md), 0 0 20px rgba(59, 130, 246, 0.1);
    }
}

.guide-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: .85rem;
    color: var(--gi-color, var(--pm-primary));
    /* Fallback */
    background: rgba(74, 127, 229, .12);
}

@supports (background: color-mix(in srgb, red 10%, white)) {
    .guide-icon {
        background: color-mix(in srgb, var(--gi-color, var(--pm-primary)) 14%, transparent);
    }
}

.guide-step-title {
    font-size: .9rem;
    font-weight: 700;
    margin-bottom: .3rem;
    color: var(--pm-text);
    line-height: 1.35;
}

.guide-step-desc {
    font-size: .8rem;
    color: var(--pm-text-muted);
    line-height: 1.55;
    margin: 0;
}

/* Step number badge */
.guide-step-num {
    position: absolute;
    top: .65rem;
    right: .65rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .68rem;
    font-weight: 700;
    color: var(--gi-color, var(--pm-primary));
    /* Fallback */
    background: rgba(74, 127, 229, .1);
    border: 1px solid rgba(255, 255, 255, 0.06);
    line-height: 1;
}

@supports (background: color-mix(in srgb, red 10%, white)) {
    .guide-step-num {
        background: color-mix(in srgb, var(--gi-color, var(--pm-primary)) 10%, transparent);
    }
}

[dir="rtl"] .guide-step-num {
    right: auto;
    left: .65rem;
}

/* ── 17. AI Modal & Dashboard Card ────────────────────────────── */
.ai-modal {
    border-radius: var(--pm-radius-lg);
    overflow: hidden;
}

.text-ai { color: #A78BFA !important; }

.ai-placeholder-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.12);
    color: #A78BFA;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 0 30px var(--pm-ai-glow);
}

.ai-coming-soon-text {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--pm-text);
}

.ai-dashboard-card {
    background: linear-gradient(135deg, var(--pm-surface) 0%, rgba(139, 92, 246, 0.08) 100%) !important;
    border: 1px solid rgba(139, 92, 246, 0.15) !important;
}

.ai-markdown h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 1.1rem 0 .45rem;
    color: var(--pm-text);
}

.ai-markdown h2:first-child { margin-top: 0; }

.ai-markdown h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: .9rem 0 .4rem;
    color: var(--pm-text);
}

.ai-markdown p {
    color: var(--pm-text);
    line-height: 1.7;
    margin-bottom: .75rem;
}

.ai-markdown ul,
.ai-markdown ol {
    padding-inline-start: 1.4rem;
    margin-bottom: .9rem;
}

.ai-markdown li {
    margin-bottom: .45rem;
    line-height: 1.65;
    color: var(--pm-text);
}

/* ── 18. Empty State ──────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--pm-text-muted);
}

/* ── 19. Forms ────────────────────────────────────────────────── */
.form-control,
.form-select {
    background-color: rgba(17, 24, 42, 0.6);
    border: 1px solid var(--pm-border-glow);
    border-radius: var(--pm-radius-sm);
    font-size: .92rem;
    color: var(--pm-text);
    transition: border-color var(--pm-transition), box-shadow var(--pm-transition);
}

.form-control::placeholder { color: var(--pm-text-light); }

.form-control:focus,
.form-select:focus {
    background-color: rgba(17, 24, 42, 0.8);
    border-color: var(--pm-primary);
    box-shadow: 0 0 0 3px var(--pm-primary-glow);
    color: var(--pm-text);
}

.form-label { font-weight: 500; font-size: .9rem; margin-bottom: .35rem; color: var(--pm-text); }

.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2394A3B8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

.form-check-input {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: var(--pm-border-glow);
}

.form-check-input:checked {
    background-color: var(--pm-primary);
    border-color: var(--pm-primary);
}

.input-group .btn-outline-secondary {
    border-color: var(--pm-border-glow);
    color: var(--pm-text-muted);
}

.input-group .btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--pm-text);
}

/* ── 20. Page header ──────────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; }

/* ── 21. Footer ───────────────────────────────────────────────── */
.app-footer {
    background: rgba(11, 15, 26, 0.8);
    backdrop-filter: var(--pm-glass-blur-sm);
    -webkit-backdrop-filter: var(--pm-glass-blur-sm);
    border-top: 1px solid var(--pm-border);
    padding: 1rem 0;
    font-size: .85rem;
}

/* ── 22. Dropdown ─────────────────────────────────────────────── */
.dropdown-menu {
    background: var(--pm-surface-solid);
    border: 1px solid var(--pm-border-glow);
    border-radius: var(--pm-radius);
    padding: .35rem .4rem;
    box-shadow: var(--pm-shadow-lg);
    backdrop-filter: var(--pm-glass-blur);
}

.dropdown-item {
    border-radius: 6px;
    font-size: .9rem;
    padding: .45rem .75rem;
    color: var(--pm-text);
    transition: background var(--pm-transition);
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--pm-text);
}

.dropdown-divider {
    border-color: var(--pm-border);
}

/* ── 23. Alert tweaks ─────────────────────────────────────────── */
.alert {
    border-radius: var(--pm-radius);
    border: 1px solid;
    backdrop-filter: var(--pm-glass-blur-sm);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    color: #4ADE80;
    border-color: rgba(34, 197, 94, 0.2);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #FCA5A5;
    border-color: rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #FBBF24;
    border-color: rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    color: #67E8F9;
    border-color: rgba(6, 182, 212, 0.2);
}

.btn-close {
    filter: invert(1) brightness(0.7);
}

/* ── 24. RTL-specific Overrides ───────────────────────────────── */
[dir="rtl"] .task-row-right { flex-direction: row-reverse; }
[dir="rtl"] .hero-subtitle  { max-width: 100%; }
[dir="rtl"] .hero-actions   { flex-direction: row-reverse; }
[dir="rtl"] .text-md-end    { text-align: start !important; }
[dir="rtl"] .feature-icon   { margin-left: 0; }
[dir="rtl"] .app-navbar .nav-link.active::after {
    left: 50%;
    right: auto;
}

/* ── 25. Plan Items (Phase 2.1) ───────────────────────────────── */
.plan-items-list {
    display: flex;
    flex-direction: column;
}

.plan-item-row {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    padding: .85rem 1.25rem;
    border-bottom: 1px solid var(--pm-border-soft);
    transition: background var(--pm-transition);
}

.plan-item-row:last-child  { border-bottom: none; }
.plan-item-row:hover       { background: rgba(255, 255, 255, 0.02); }
.plan-item-row.plan-item-done { opacity: .55; }

.plan-item-check-wrap {
    display: flex;
    align-items: center;
    padding-top: .15rem;
    flex-shrink: 0;
}

.plan-item-check-wrap .form-check-input {
    width: 1.05em;
    height: 1.05em;
    cursor: pointer;
    flex-shrink: 0;
}

.plan-item-body {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    flex: 1;
    min-width: 0;
}

.plan-item-body.clickable { cursor: pointer; }

.plan-item-order {
    font-size: .78rem;
    font-weight: 700;
    color: var(--pm-text-muted);
    flex-shrink: 0;
    min-width: 1.4rem;
}

.plan-item-content {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-width: 0;
}

.plan-item-title {
    font-size: .9rem;
    font-weight: 600;
    color: var(--pm-text);
    line-height: 1.35;
}

.plan-item-desc {
    font-size: .8rem;
    color: var(--pm-text-muted);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.plan-item-meta {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.plan-item-time {
    font-size: .75rem;
    color: var(--pm-text-muted);
    white-space: nowrap;
}

.plan-items-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .85rem 1.25rem;
    border-top: 1px solid var(--pm-border);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 0 0 var(--pm-radius) var(--pm-radius);
}

/* ── 26. Scroll Reveal Animations ─────────────────────────────── */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .5s ease, transform .5s ease;
}

.reveal-on-scroll.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Completed task cards keep their reduced opacity after reveal */
.task-card.task-done.reveal-on-scroll.revealed { opacity: .55; }
.plan-item-row.plan-item-done.reveal-on-scroll.revealed { opacity: .55; }

/* ── 27. Bootstrap dark-mode overrides ────────────────────────── */
[data-bs-theme="dark"] .modal-content {
    background: var(--pm-surface-solid);
    border: 1px solid var(--pm-border-glow);
}

[data-bs-theme="dark"] .progress {
    background-color: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .progress-bar {
    border-radius: 999px;
}

[data-bs-theme="dark"] .text-muted {
    color: var(--pm-text-muted) !important;
}

[data-bs-theme="dark"] .text-primary {
    color: var(--pm-primary-light) !important;
}

[data-bs-theme="dark"] .text-danger {
    color: #F87171 !important;
}

[data-bs-theme="dark"] .text-success {
    color: #4ADE80 !important;
}

[data-bs-theme="dark"] .text-info {
    color: #67E8F9 !important;
}

[data-bs-theme="dark"] .fw-semibold {
    color: var(--pm-text);
}

[data-bs-theme="dark"] .table {
    color: var(--pm-text);
    border-color: var(--pm-border);
}

[data-bs-theme="dark"] h5, 
[data-bs-theme="dark"] h4,
[data-bs-theme="dark"] h3 {
    color: var(--pm-text);
}

[data-bs-theme="dark"] .card {
    background: var(--pm-surface);
    border-color: var(--pm-border);
}

/* ── 28. Scrollbar Styling ────────────────────────────────────── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--pm-bg);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ── 29. Selection Color ──────────────────────────────────────── */
::selection {
    background: rgba(59, 130, 246, 0.35);
    color: #fff;
}

/* ── 30. Responsive ───────────────────────────────────────────── */

/* ── Tablet & below (≤991px) ──────────────────────────────────── */
@media (max-width: 991.98px) {
    .hero-section { padding: 3rem 0 2.5rem; }
    .hero-title   { font-size: 1.9rem; }
    .ambient-orb  { opacity: .15; }

    /* Container breathing room */
    .container { padding-left: 1rem; padding-right: 1rem; }

    /* Stat cards: smaller padding */
    .stat-card { padding: .9rem .75rem; }
    .stat-num  { font-size: 1.7rem; }
    .stat-icon { font-size: 1.3rem; }

    /* Task card actions stay accessible */
    .task-card-top { gap: .5rem; }
    .task-actions { gap: .15rem; }
}

/* ── Phone landscape & below (≤767px) ─────────────────────────── */
@media (max-width: 767.98px) {
    .hero-title { font-size: 1.65rem; }
    .hero-subtitle { font-size: .95rem; max-width: 100%; }
    .hero-badge { font-size: .72rem; padding: .25rem .7rem; }
    .hero-actions { flex-direction: column; gap: .5rem; }
    .hero-actions .btn { width: 100%; text-align: center; }

    .auth-card { padding: 1.5rem 1.25rem; }
    .auth-title { font-size: 1.3rem; }

    .page-title { font-size: 1.3rem; }
    .page-subtitle { font-size: .82rem; }
    .stat-num { font-size: 1.5rem; }
    .stat-label { font-size: .62rem; }

    /* Page header stacks vertically */
    .page-header.d-flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: .75rem;
    }
    .page-header .d-flex { flex-wrap: wrap; gap: .4rem; }
    .page-header .btn { font-size: .82rem; padding: .4rem .75rem; }

    /* Task cards: wrap top section */
    .task-card-top { flex-wrap: wrap; }
    .task-card-body { padding: .8rem .9rem; }
    .task-card-title { font-size: .88rem; }
    .task-card-desc { font-size: .8rem; -webkit-line-clamp: 1; }
    .task-card-meta { gap: .3rem; }

    /* Task row (dashboard) */
    .task-row { padding: .65rem .9rem; gap: .5rem; }
    .task-title { font-size: .88rem; }
    .task-badge { font-size: .6rem !important; }

    /* Subtasks */
    .subtask-nest {
        margin-inline-start: 1rem;
        padding-inline-start: .75rem;
    }
    .subtask-toggle { font-size: .72rem; padding: .25rem .55rem; }
    .subtask-title { font-size: .85rem; }
    .subtask-desc { font-size: .78rem; }

    /* Filter card */
    .app-card .card-body.py-3 { padding: .75rem !important; }
    .form-select-sm, .form-control-sm { font-size: .8rem; }

    /* Badges smaller on mobile */
    .badge { font-size: .65rem; padding: .22em .5em; }
    .org-chip, .tag-pill { font-size: .7rem; padding: .2rem .5rem; }

    /* Project mini cards */
    .project-mini-card { padding: .7rem; }

    /* Ambient: reduce for performance */
    .ambient-orb { opacity: .1; }

    /* Features */
    .feature-card { padding: 1.25rem 1rem; }
    .feature-title { font-size: .95rem; }
    .feature-desc { font-size: .82rem; }
    .feature-icon { width: 42px; height: 42px; font-size: 1.2rem; }

    /* Settings */
    .card-header { padding: .8rem 1rem; }
    .card-header h5 { font-size: .95rem; }

    /* AI dashboard card */
    .ai-dashboard-card .card-body { padding: 1rem !important; }
}

/* ── Phone portrait & below (≤575px) ──────────────────────────── */
@media (max-width: 575.98px) {
    .hero-section { padding: 2rem 0 1.5rem; }
    .hero-title { font-size: 1.45rem; }

    .features-section { padding: 2.5rem 0; }
    .section-title { font-size: 1.35rem; }

    .auth-page { align-items: flex-start; padding-top: 1.25rem; }
    .auth-card { padding: 1.25rem 1rem 1.5rem; border-radius: var(--pm-radius); }

    /* Stat grid: tighter */
    .stat-card { padding: .75rem .6rem; }
    .stat-num { font-size: 1.35rem; }
    .stat-icon { font-size: 1.15rem; margin-bottom: .3rem; }
    .stat-label { font-size: .58rem; letter-spacing: .03em; }
    .stat-card::before { height: 1.5px; }

    /* Task cards: full-width friendly */
    .task-card { border-radius: var(--pm-radius-sm); }
    .task-card-body { padding: .7rem .8rem; }
    .task-actions .btn-icon { width: 28px; height: 28px; }

    /* Buttons: full-width on small screens */
    .page-header .btn { width: 100%; justify-content: center; }

    /* Plan items */
    .plan-item-row { padding: .7rem .9rem; gap: .6rem; }
    .plan-item-title { font-size: .82rem; }
    .plan-item-desc { font-size: .74rem; }

    /* Ambient orbs: scale down */
    .ambient-orb-1 { width: 250px; height: 250px; }
    .ambient-orb-2 { width: 200px; height: 200px; }
    .ambient-orb-3 { width: 180px; height: 180px; }

    /* Footer */
    .app-footer { font-size: .78rem; }
    .app-footer .row { gap: .25rem; }

    /* Dropdown */
    .dropdown-menu { min-width: auto; }

    /* Container: less side padding */
    .container { padding-left: .75rem; padding-right: .75rem; }
    .py-4 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
}

/* ── Very small phones (≤390px) ───────────────────────────────── */
@media (max-width: 390px) {
    .hero-title { font-size: 1.3rem; }
    .stat-num { font-size: 1.2rem; }
    .stat-label { font-size: .55rem; }
    .page-title { font-size: 1.15rem; }
    .task-card-title { font-size: .82rem; }
    .app-brand { font-size: 1rem; }
    .brand-dot { width: 8px; height: 8px; }
}
