/* Aum Space - theme.
   Palette/typography modeled after a vibrant SaaS-dashboard look
   (Plus Jakarta Sans, soft pastel-tint icon chips, pill badges/search,
   large rounded cards with soft shadows). --accent is set inline
   per-user (see layouts/app.php); everything else derives from it or
   from the light/dark palette below. */

:root {
    --font: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;

    --accent: #3385f0;
    --accent-ink: #ffffff;

    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #eef1f8;
    --border: #e7eaf3;
    --text: #1b2124;
    --text-muted: #6b7480;

    --sidebar-bg: #ffffff;
    --sidebar-border: #eef0f7;
    --sidebar-text: #6b7480;
    --sidebar-active-bg: color-mix(in srgb, var(--accent) 12%, white);
    --sidebar-active-text: var(--accent);

    --radius: 18px;
    --radius-sm: 12px;
    --radius-pill: 999px;
    --shadow: 0 10px 30px rgba(30, 41, 74, 0.06);
    --shadow-lift: 0 16px 36px rgba(30, 41, 74, 0.12);

    --success: #0ea968;
    --success-ink: #066f49;
    --success-bg: rgba(14, 169, 104, .15);
    --warning: #f68d2a;
    --warning-ink: #ac631d;
    --warning-bg: rgba(246, 141, 42, .15);
    --danger: #ef4444;
    --danger-ink: #b91c1c;
    --danger-bg: rgba(239, 68, 68, .15);
}

[data-theme="dark"] {
    --bg: #12141c;
    --surface: #1b1e29;
    --surface-2: #232636;
    --border: #2b2e40;
    --text: #eceefb;
    --text-muted: #9497ae;

    --sidebar-bg: #171a24;
    --sidebar-border: #262a3a;
    --sidebar-text: #9497ae;
    --sidebar-active-bg: color-mix(in srgb, var(--accent) 18%, transparent);
    --sidebar-active-text: color-mix(in srgb, var(--accent) 70%, white);

    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-lift: 0 18px 40px rgba(0, 0, 0, 0.5);
}

/* Eight-color accent rotation for module icons/tiles, cycling by index
   (see helpers::accent_class() used in views). Soft tint bg + solid icon color,
   the same "chip" formula the palette above uses for success/warning/danger. */
.accent-0 .icon { background: rgba(51, 133, 240, .15); color: #3385f0; }
.accent-1 .icon { background: rgba(14, 169, 104, .15); color: #0ea968; }
.accent-2 .icon { background: rgba(124, 92, 252, .15); color: #7c5cfc; }
.accent-3 .icon { background: rgba(246, 141, 42, .15); color: #f68d2a; }
.accent-4 .icon { background: rgba(236, 72, 153, .15); color: #ec4899; }
.accent-5 .icon { background: rgba(20, 184, 166, .15); color: #14b8a6; }
.accent-6 .icon { background: rgba(244, 63, 94, .15); color: #f43f5e; }
.accent-7 .icon { background: rgba(234, 179, 8, .15); color: #b7860b; }

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    min-height: 100vh;
    font-size: .95rem;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--font); font-weight: 700; letter-spacing: -0.01em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 264px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 1.5rem 1.1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--sidebar-border);
}

.app-sidebar .brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: var(--text);
    font-weight: 800;
    font-size: 1.25rem;
    margin-bottom: 1.75rem;
    padding: 0 .4rem;
}

.app-sidebar .brand .logo-mark {
    width: 36px; height: 36px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 40%, #7c5cfc));
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
    box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 45%, transparent);
    flex-shrink: 0;
}

.app-sidebar nav a {
    display: flex;
    align-items: center;
    gap: .7rem;
    color: var(--sidebar-text);
    padding: .55rem .7rem;
    border-radius: var(--radius-sm);
    margin-bottom: .2rem;
    font-size: .9rem;
    font-weight: 600;
}

.app-sidebar nav a .icon {
    width: 30px; height: 30px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: .95rem;
    flex-shrink: 0;
    margin-bottom: 0;
}

.app-sidebar nav a:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}

.app-sidebar nav a.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    text-decoration: none;
}

.app-sidebar nav a.active .icon {
    background: var(--surface);
    color: var(--sidebar-active-text);
}

.app-sidebar .section-label {
    text-transform: uppercase;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .09em;
    color: var(--text-muted);
    opacity: .7;
    margin: 1.3rem .7rem .5rem;
}

.app-main { flex: 1; min-width: 0; }

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.75rem;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-search {
    flex: 1;
    max-width: 420px;
    position: relative;
}

.topbar-search input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    padding: .55rem 1rem .55rem 2.4rem;
    color: var(--text);
    font-size: .88rem;
    font-family: var(--font);
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
}

.topbar-search i {
    position: absolute;
    left: .9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.icon-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }

.app-content { padding: 0 1.75rem 1.75rem; }

.page-heading {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: .2rem;
}

.card-surface {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

a.card-surface {
    transition: transform .15s ease, box-shadow .15s ease;
}
a.card-surface:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lift);
    text-decoration: none;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.35rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card .icon {
    width: 50px; height: 50px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-card .stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { font-size: .82rem; color: var(--text-muted); font-weight: 600; }

a.stat-card { transition: transform .15s ease, box-shadow .15s ease; min-width: 0; }
a.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); text-decoration: none; }

.module-tile {
    display: block;
    padding: 1.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform .15s ease, box-shadow .15s ease;
    height: 100%;
}

.module-tile:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lift);
    text-decoration: none;
}

.module-tile .icon {
    width: 48px; height: 48px;
    border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    margin-bottom: .9rem;
}

.module-tile .fw-semibold { font-size: 1rem; }

.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    border-radius: var(--radius-sm);
    font-weight: 700;
}
.btn-accent:hover { filter: brightness(1.06); color: var(--accent-ink); }

.btn, .btn-sm { border-radius: var(--radius-sm); font-weight: 600; }

.text-muted-soft { color: var(--text-muted); }

/* Soft pill badges (chip pattern: tinted bg + saturated text, no solid fills) */
.badge-visibility-private,
.badge-visibility-shared,
.badge-visibility-public {
    border-radius: var(--radius-pill);
    font-weight: 700;
    padding: .3em .7em;
}
.badge-visibility-private { background: var(--surface-2); color: var(--text-muted); }
.badge-visibility-shared { background: var(--warning-bg); color: var(--warning-ink); }
.badge-visibility-public { background: var(--success-bg); color: var(--success-ink); }

.chip-success { background: var(--success-bg); color: var(--success-ink); }
.chip-warning { background: var(--warning-bg); color: var(--warning-ink); }
.chip-danger { background: var(--danger-bg); color: var(--danger-ink); }

.form-control, .form-select {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-family: var(--font);
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--accent) 25%, transparent);
    background: var(--surface);
    color: var(--text);
}

.table { color: var(--text); }

/* Bootstrap component overrides so they follow the theme instead of
   Bootstrap's own hardcoded blues/grays. */
.list-group-item {
    background: transparent;
    border: none;
    color: var(--text);
    border-radius: var(--radius-sm) !important;
    margin-bottom: .25rem;
    font-weight: 600;
    padding: .6rem .9rem;
}
.list-group-item-action:hover,
.list-group-item-action:focus {
    background: var(--surface-2);
    color: var(--text);
}
.list-group-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    border-color: transparent;
}

.badge { border-radius: var(--radius-pill); font-weight: 700; padding: .4em .75em; }

.nav-pills .nav-link {
    border-radius: var(--radius-pill);
    color: var(--text-muted);
    font-weight: 700;
    padding: .5rem 1.1rem;
}
.nav-pills .nav-link.active { background: var(--accent); color: var(--accent-ink); }

.dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lift);
}
.dropdown-item { color: var(--text); font-weight: 600; border-radius: 8px; margin: 0 .3rem; width: calc(100% - .6rem); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2); color: var(--text); }
.dropdown-header { color: var(--text-muted); font-weight: 700; }

.alert { border-radius: var(--radius-sm); border: none; font-weight: 600; }
.alert-success { background: var(--success-bg); color: var(--success-ink); }
.alert-danger { background: var(--danger-bg); color: var(--danger-ink); }
.alert-warning { background: var(--warning-bg); color: var(--warning-ink); }

.color-swatch {
    width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    display: inline-block;
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 12% 18%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 42%),
        radial-gradient(circle at 88% 82%, color-mix(in srgb, #7c5cfc 35%, transparent), transparent 45%),
        #12141c;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: 24px;
    box-shadow: 0 30px 70px rgba(0,0,0,.35);
    padding: 2.25rem;
}

@media (max-width: 860px) {
    .app-sidebar { position: fixed; left: -280px; z-index: 1000; transition: left .2s ease; }
    .app-sidebar.open { left: 0; }
    .app-shell { display: block; }
    .topbar-search { display: none; }
}

/* Global image lightbox - any <img data-lightbox="fullSrc" data-lightbox-caption="..">
   anywhere in the app opens here (see app.js). One overlay, reused everywhere. */
.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 24, 0.92);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.lightbox-overlay.open { display: flex; }

.lightbox-overlay img {
    max-width: 100%;
    max-height: 82vh;
    border-radius: var(--radius-sm);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
    position: absolute;
    bottom: 2rem;
    left: 0;
    right: 0;
    text-align: center;
    color: #fff;
    font-weight: 600;
}

.lightbox-close {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    width: 42px; height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: none;
    font-size: 1.3rem;
    display: flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.22); }

/* Overdue subscription payment attention states (Āṅgaṇ Subscription/Payment
   Reminders). Blinking is deliberately time-limited to the first 3 days
   overdue (see AnganController::buildSubscriptionReminders) - a permanent
   pulse would just become wallpaper you stop noticing. */
@keyframes overdue-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .55); }
    50% { box-shadow: 0 0 0 9px rgba(239, 68, 68, 0); }
}
.overdue-blink {
    border-color: #ef4444 !important;
    animation: overdue-pulse 1.4s ease-in-out infinite;
}
.overdue-plain {
    border-color: #ef4444 !important;
}

/* Tasks module: one task row is a <details> element so it expands into its
   own edit form inline, with no JS and no per-row modal. */
.task-row {
    border-bottom: 1px solid var(--border, rgba(0, 0, 0, .06));
}
.task-row:last-child { border-bottom: none; }
.task-row summary {
    list-style: none;
    cursor: pointer;
    padding-left: .5rem;
    padding-right: .5rem;
    border-radius: 10px;
}
.task-row summary::-webkit-details-marker { display: none; }
.task-row summary:hover { background: rgba(99, 102, 241, .06); }
.task-row[open] summary .bi-chevron-down { transform: rotate(180deg); }
.task-row-body {
    padding: .5rem .75rem 1rem;
    background: rgba(99, 102, 241, .03);
    border-radius: 10px;
}
.task-row.task-overdue summary { background: rgba(244, 63, 94, .06); }
.task-check {
    background: none;
    border: none;
    padding: 0;
    font-size: 1.1rem;
    color: var(--text-muted, #9ca3af);
    line-height: 1;
}
.task-check.checked { color: #22c55e; }
.priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Wiki module: the page tree sidebar and the read-only view for people who
   can't edit. The editor itself is styled by Quill's own "snow" theme. */
.wiki-tree, .wiki-tree ul {
    list-style: none;
    margin: 0;
    padding-left: .9rem;
}
.wiki-tree { padding-left: 0; }
.wiki-tree li { margin: 1px 0; }
.wiki-tree a {
    display: block;
    padding: .3rem .5rem;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wiki-tree a:hover { background: rgba(99, 102, 241, .08); }
.wiki-tree a.active { background: rgba(99, 102, 241, .14); font-weight: 600; }
.wiki-tree i { font-size: .8rem; margin-right: 4px; color: var(--text-muted, #9ca3af); }
#wiki-editor .ql-editor { min-height: 400px; }
.wiki-readonly img, #wiki-editor img { max-width: 100%; border-radius: 8px; }
