/**
 * Evolve — App-level styling on top of Bootstrap 5 + AdminLTE 4.
 *
 * Theme baseline (sidebar/topbar/primary color) is database-driven and injected
 * by themeHeadStyles() in includes/functions.php. This file only carries:
 *   - Design tokens (radius, shadow, brand accents) for use in markup.
 *   - Component refinements that are NOT covered by Bootstrap utilities.
 *   - Print rules.
 *
 * Avoid:
 *   - Hardcoded colors that duplicate --bs-primary or --evl-* (driven by /settings/theme).
 *   - !important (use higher specificity or a new class instead).
 *   - Dead overrides for elements that don't exist in markup.
 */

/* Notification dropdown — let long titles wrap instead of blowing past the menu edge. */
.notification-item {
    white-space: normal;
    word-break: break-word;
}
.notification-item .fw-semibold { line-height: 1.3; }
.min-w-0 { min-width: 0; }

/* ============================================================
   Design tokens
   ============================================================ */
:root {
    --evl-radius-sm: 0.375rem;
    --evl-radius:    0.5rem;
    --evl-radius-lg: 0.75rem;

    --evl-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --evl-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --evl-shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --evl-shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);

    --evl-border:        #e5e7eb;
    --evl-surface:       #ffffff;
    --evl-surface-muted: #f8fafc;

    /* Brand accents — kept here so swaps are a one-edit. */
    --evl-accent-whatsapp:       #25D366;
    --evl-accent-whatsapp-hover: #1da851;
    --evl-accent-certificate:    #f59e0b;
}

/* ============================================================
   Body / layout
   ============================================================ */
body {
    background-color: var(--evl-surface-muted);
    color: #1f2937;
}

.app-wrapper {
    min-height: 100vh;
}

.app-content {
    padding-top: 1rem;
    padding-bottom: 2rem;
}

/* Wizard syllabus rows marked "not kept" (will be soft-deleted on commit). */
.syl-row-dropped input,
.syl-row-dropped textarea,
.syl-row-dropped select {
    text-decoration: line-through;
    color: #6b7280;
    background: #f1f5f9;
}
.syl-row-dropped button { opacity: .5; }

/* ============================================================
   Quill rich-text editor — Quill's defaults strip block spacing,
   so headings, paragraphs and lists visually run together. Restore
   readable spacing + heading hierarchy inside .ql-editor.
   ============================================================ */
.ql-editor {
    font-size: 0.95rem;
    line-height: 1.55;
    padding: 0.75rem 1rem;
}
.ql-editor p + p,
.ql-editor ul + p,
.ql-editor ol + p,
.ql-editor h1 + p,
.ql-editor h2 + p,
.ql-editor h3 + p,
.ql-editor h4 + p { margin-top: 0.6rem; }
.ql-editor h1,
.ql-editor h2,
.ql-editor h3,
.ql-editor h4 {
    margin-top: 1rem;
    margin-bottom: 0.35rem;
    font-weight: 600;
    line-height: 1.25;
}
.ql-editor h1 { font-size: 1.45rem; }
.ql-editor h2 { font-size: 1.25rem; }
.ql-editor h3 { font-size: 1.1rem; }
.ql-editor h4 { font-size: 1rem; color: #334155; }
.ql-editor ul,
.ql-editor ol {
    margin: 0.35rem 0 0.6rem;
    padding-left: 1.5rem;
}
.ql-editor li + li { margin-top: 0.15rem; }
.ql-editor strong { font-weight: 600; }

/* Read-only render of Quill-authored HTML (outside the editor). Mirrors the
   spacing rules above so display pages look identical to the editor preview. */
.ql-content { line-height: 1.55; }
.ql-content > p { margin-bottom: 0.5rem; }
.ql-content > p:last-child { margin-bottom: 0; }
.ql-content h1,
.ql-content h2,
.ql-content h3,
.ql-content h4 { margin-top: 0.75rem; margin-bottom: 0.35rem; font-weight: 600; line-height: 1.25; }
.ql-content h1 { font-size: 1.45rem; }
.ql-content h2 { font-size: 1.25rem; }
.ql-content h3 { font-size: 1.1rem; }
.ql-content h4 { font-size: 1rem; color: #334155; }
.ql-content ul,
.ql-content ol { margin: 0.35rem 0 0.6rem; padding-left: 1.5rem; }
.ql-content li + li { margin-top: 0.15rem; }

/* ============================================================
   Sidebar accent — colors come from --evl-sidebar-* (theme()).
   Here we just refine spacing and add the primary stripe on active items.
   ============================================================ */
.app-sidebar .nav-link {
    border-radius: var(--evl-radius-sm);
    margin: 0 0.5rem;
    padding: 0.375rem 0.75rem;
    transition: background-color 0.15s ease;
    line-height: 1.3;
}

.app-sidebar .nav-header {
    padding: 0.5rem 0.75rem 0.25rem;
    margin-top: 0.25rem;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
}

.app-sidebar .nav-link.active {
    position: relative;
}

.app-sidebar .nav-link.active::before {
    content: "";
    position: absolute;
    left: -0.5rem;
    top: 0.25rem;
    bottom: 0.25rem;
    width: 3px;
    border-radius: 2px;
    background: var(--bs-primary);
}

/* ============================================================
   Program / course thumbnail tile — mobile-first 16:9.
   Used via <img class="program-thumb"> on every learner-facing
   surface (programs list, my-programs, guest enrol, learning
   shell). Fluid width, no inline height needed.
   ============================================================ */
.program-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
    background: var(--evl-surface-muted);
    border-radius: var(--evl-radius) var(--evl-radius) 0 0;
}

/* ============================================================
   Cards — flat, soft shadow, no hover lift.
   ============================================================ */
.card {
    border: 1px solid var(--evl-border);
    border-radius: var(--evl-radius);
    box-shadow: var(--evl-shadow-xs);
    background-color: var(--evl-surface);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--evl-border);
    padding: 0.875rem 1rem;
}

.card-header .card-title {
    margin-bottom: 0;
    font-size: 1rem;
    font-weight: 600;
}

/* ============================================================
   AdminLTE small-box stat tiles — centered, icon on top.
   Overrides AdminLTE's default left-aligned layout for a cleaner KPI look.
   ============================================================ */
.small-box {
    border-radius: var(--evl-radius);
    position: relative;
    overflow: hidden;
    box-shadow: var(--evl-shadow-sm);
    text-align: center;
}

.small-box .inner {
    padding: 1.5rem 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.small-box .inner h3 {
    font-size: 2.25rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.1;
}

.small-box .inner p {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.95;
}

/* Icon: top-center, bigger, fully visible (no longer a watermark). */
.small-box .icon {
    position: static;
    transform: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin: 0 auto 0.75rem;
    font-size: 1.75rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
    order: -1;
}

.small-box .small-box-footer {
    background: rgba(0, 0, 0, 0.12);
    color: inherit;
    display: block;
    padding: 0.5rem 1rem;
    text-align: center;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.small-box .small-box-footer:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* ============================================================
   Forms, tables, buttons — light touch only
   ============================================================ */
.btn {
    border-radius: var(--evl-radius-sm);
    font-weight: 500;
}

.form-control,
.form-select {
    border-radius: var(--evl-radius-sm);
}

.table {
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: 0.625rem 0.75rem;
}

.table thead th {
    background-color: var(--evl-surface-muted);
    border-bottom: 1px solid var(--evl-border);
    font-weight: 600;
    font-size: 0.8125rem;
    color: #475569;
}

.table tbody tr:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.04);
}

/* Bootstrap badge default is fine; just bump padding so they don't crowd. */
.badge {
    font-weight: 500;
    padding: 0.35rem 0.55rem;
}

/* ============================================================
   Dropdown polish
   ============================================================ */
.dropdown-menu {
    border: 1px solid var(--evl-border);
    box-shadow: var(--evl-shadow-md);
    border-radius: var(--evl-radius);
    padding: 0.375rem;
}

.dropdown-item {
    border-radius: var(--evl-radius-sm);
    padding: 0.5rem 0.75rem;
}

/* ============================================================
   Breadcrumb
   ============================================================ */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 0;
    font-size: 0.875rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: #94a3b8;
}

/* ============================================================
   Notification badge (used on bell icon in topbar)
   ============================================================ */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0.65rem;
    padding: 0.2rem 0.4rem;
    border-radius: 50%;
}

/* ============================================================
   Login page
   ============================================================ */
.login-box .card {
    border-radius: var(--evl-radius-lg);
    box-shadow: var(--evl-shadow-lg);
    border: 1px solid var(--evl-border);
}

.login-box .btn-whatsapp {
    background-color: var(--evl-accent-whatsapp);
    border-color: var(--evl-accent-whatsapp);
    color: #fff;
}

.login-box .btn-whatsapp:hover {
    background-color: var(--evl-accent-whatsapp-hover);
    border-color: var(--evl-accent-whatsapp-hover);
    color: #fff;
}

.otp-input {
    letter-spacing: 0.75rem;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
}

/* ============================================================
   Page-specific helpers
   ============================================================ */
.leaderboard-podium .card {
    transition: transform 0.2s ease;
}

.leaderboard-podium .card:hover {
    transform: translateY(-3px);
}

.certificate-preview {
    border: 2px solid var(--evl-accent-certificate);
    border-radius: var(--evl-radius);
    background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
}

.achievement-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border-radius: var(--evl-radius);
    background: var(--evl-surface-muted);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.achievement-badge:hover {
    transform: translateY(-3px);
    box-shadow: var(--evl-shadow-md);
}

/* ============================================================
   Loading spinner overlay
   ============================================================ */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ============================================================
   Animation utilities
   ============================================================ */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

/* Optional gradient utilities — use only on heroes/marketing-style blocks. */
.bg-gradient-primary { background: linear-gradient(135deg, var(--bs-primary) 0%, #6610f2 100%); }
.bg-gradient-success { background: linear-gradient(135deg, #198754 0%, #20c997 100%); }
.bg-gradient-warning { background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%); }
.bg-gradient-danger  { background: linear-gradient(135deg, #dc3545 0%, #e83e8c 100%); }
.bg-gradient-info    { background: linear-gradient(135deg, #0dcaf0 0%, var(--bs-primary) 100%); }

/* ============================================================
   Responsive tweaks
   ============================================================ */
@media (max-width: 768px) {
    .small-box .inner h3 { font-size: 1.75rem; }
    .small-box .icon {
        width: 44px;
        height: 44px;
        font-size: 1.4rem;
        margin-bottom: 0.5rem;
    }
}

/* ============================================================
   Print — single source of truth for the whole app.
   Per-report print views live in modules/reports/_lib.php.
   ============================================================ */
@media print {
    .app-sidebar,
    .app-header,
    .breadcrumb,
    .card-tools,
    .pagination,
    .d-print-none {
        display: none !important;
    }

    .app-main {
        margin-left: 0 !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
