/* Html2Image app styles (dashboard, admin, auth pages).
   Loaded by Layout::head() as a cacheable, versioned file instead of
   ~540 lines of inline <style> on every page. */

/* =====================================================
   UNIFIED DESIGN SYSTEM v2.0
   Html2Image - Consistent across ALL pages
   ===================================================== */

/* =====================================================
   TYPOGRAPHY - Consistent font weights everywhere
   ===================================================== */
body { 
    background: #fff; 
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 1.6;
    color: #444;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: #333;
    margin-top: 0;
}
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }
h5 { font-size: 14px; }
h6 { font-size: 13px; }

p { margin-bottom: 15px; }
strong, b { font-weight: 600; }

/* Base Layout */
.page-content {
    padding-top: 50px;
    min-height: calc(100vh - 250px);
    background: #f8f9fa;
    padding-bottom: 40px;
}

/* Cards - White boxes with shadow */
.page-card { 
    background: white; 
    border-radius: 10px; 
    padding: 30px; 
    box-shadow: 0 2px 12px rgba(0,0,0,0.08); 
    margin-bottom: 25px; 
}

/* Page Title & Subtitle - UNIFIED */
.page-title { 
    margin: 0 0 8px; 
    color: #333; 
    font-size: 22px;
    font-weight: 600;
    display: flex;
    align-items: center;
}
.page-title i { 
    margin-right: 12px; 
    color: #C24F4F;
    font-size: 20px;
}
.page-subtitle { 
    color: #777; 
    margin-bottom: 25px; 
    font-size: 14px;
    font-weight: 400;
}

/* =====================================================
   SIDEBAR - Consistent for Dashboard AND Admin
   ===================================================== */
.sidebar { 
    background: white; 
    border-radius: 10px; 
    padding: 20px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.08); 
    margin-bottom: 20px; 
    position: sticky; 
    top: 100px; 
}
.sidebar-title { 
    font-size: 11px; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    margin-bottom: 15px; 
    padding-bottom: 12px; 
    border-bottom: 2px solid #f0f0f0; 
}
.sidebar-title.dashboard { color: #C24F4F; }
.sidebar-title.admin { color: #dc3545; }

.sidebar-nav { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
}
.sidebar-nav li { margin-bottom: 3px; }
.sidebar-nav a { 
    display: flex; 
    align-items: center; 
    padding: 10px 15px; 
    color: #555; 
    text-decoration: none; 
    border-radius: 6px; 
    transition: all 0.2s; 
    font-size: 14px;
}
.sidebar-nav a:hover { 
    background: #f8f8f8; 
    color: #C24F4F; 
    text-decoration: none;
}
.sidebar-nav a.active { 
    background: #C24F4F; 
    color: white; 
}
.sidebar-nav a.active:hover { 
    background: #b34545; 
    color: white; 
}
.sidebar-nav a i { 
    margin-right: 10px; 
    width: 18px; 
    text-align: center; 
    font-size: 14px;
}
.sidebar-divider { 
    height: 1px; 
    background: #eee; 
    margin: 15px 0; 
    list-style: none; 
}
.sidebar-nav a.admin-link { color: #dc3545; }
.sidebar-nav a.admin-link:hover { background: #fff5f5; }

/* =====================================================
   BUTTONS - Unified sizes and styles
   ===================================================== */
.btn-unified {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.btn-unified:hover { 
    text-decoration: none; 
    opacity: 0.9;
    transform: translateY(-1px);
}
.btn-unified i { margin-right: 6px; }

/* Button Sizes */
.btn-unified.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}
.btn-unified.btn-lg {
    padding: 12px 24px;
    font-size: 14px;
}
.btn-unified.btn-xs {
    padding: 4px 8px;
    font-size: 10px;
}

/* Button Colors */
.btn-unified.btn-primary { background: #C24F4F; color: white; }
.btn-unified.btn-primary:hover { background: #a84040; color: white; }

.btn-unified.btn-success { background: #27ae60; color: white; }
.btn-unified.btn-success:hover { background: #219a52; color: white; }

.btn-unified.btn-warning { background: #f39c12; color: white; }
.btn-unified.btn-warning:hover { background: #d68910; color: white; }

.btn-unified.btn-danger { background: #e74c3c; color: white; }
.btn-unified.btn-danger:hover { background: #c0392b; color: white; }

.btn-unified.btn-secondary { background: #6c757d; color: white; }
.btn-unified.btn-secondary:hover { background: #5a6268; color: white; }

.btn-unified.btn-info { background: #3498db; color: white; }
.btn-unified.btn-info:hover { background: #2980b9; color: white; }

.btn-unified.btn-dark { background: #343a40; color: white; }
.btn-unified.btn-dark:hover { background: #23272b; color: white; }

/* Legacy button override for consistency */
.btn {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}
.btn-lg {
    padding: 12px 24px;
    font-size: 14px;
}
.btn-xs {
    padding: 4px 8px;
    font-size: 10px;
}

/* =====================================================
   STAT CARDS - Unified statistics display
   ===================================================== */
.stat-card { 
    text-align: center; 
    padding: 20px 15px; 
}
.stat-card h3 { 
    color: #C24F4F; 
    font-size: 1.8rem; 
    font-weight: 700; 
    margin: 0; 
    line-height: 1;
}
.stat-card p { 
    color: #888; 
    margin: 8px 0 0; 
    font-size: 12px; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Mini stat cards for admin */
.stat-mini { 
    background: white; 
    border-radius: 8px; 
    padding: 18px 15px; 
    text-align: center; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.06); 
}
.stat-mini h4 { 
    margin: 0; 
    color: #C24F4F; 
    font-size: 1.5rem; 
    font-weight: 700;
}
.stat-mini p { 
    margin: 5px 0 0; 
    color: #888; 
    font-size: 11px; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =====================================================
   BADGES - Unified status indicators
   ===================================================== */
.badge-status {
    display: inline-block;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    color: white;
}
.badge-status.success, .badge-status.active, .badge-status.verified { background: #27ae60; }
.badge-status.warning, .badge-status.pending { background: #f39c12; }
.badge-status.danger, .badge-status.error, .badge-status.inactive { background: #e74c3c; }
.badge-status.info { background: #3498db; }
.badge-status.secondary, .badge-status.disabled { background: #95a5a6; }
.badge-status.admin { background: #C24F4F; }

/* =====================================================
   TABLES - Unified table styling (no horizontal scroll)
   ===================================================== */
.table-card {
    overflow-x: visible;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    padding: 0;
    margin-bottom: 20px;
}
.page-card .table-card {
    box-shadow: none;
    margin-bottom: 0;
    border-radius: 0;
}
.page-card .table-card table thead tr:first-child th:first-child { border-top-left-radius: 0; }
.page-card .table-card table thead tr:first-child th:last-child { border-top-right-radius: 0; }
.table-card table {
    margin: 0;
    width: 100%;
    table-layout: fixed;
}
.table-card table thead tr:first-child th:first-child { border-top-left-radius: 10px; }
.table-card table thead tr:first-child th:last-child { border-top-right-radius: 10px; }
.table th {
    border-top: none !important;
    background: #f8f9fa;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    font-weight: 600;
    padding: 10px 8px !important;
}
.table td {
    padding: 10px 8px !important;
    vertical-align: middle !important;
    font-size: 13px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.table-hover tbody tr:hover {
    background-color: #f8f9fa;
}
/* Table helper classes */
.cell-truncate {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cell-wrap {
    word-break: break-all;
    max-width: 200px;
}
.cell-email {
    word-break: break-all;
    font-size: 12px;
}
.cell-actions {
    white-space: nowrap;
}
.cell-actions form {
    display: inline-block;
    margin: 1px 0;
}
.btn-action {
    padding: 4px 8px;
    font-size: 10px;
    margin: 1px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: inline-block;
}
.btn-action:hover { opacity: 0.85; }

/* =====================================================
   FORMS - Unified form styling
   ===================================================== */
.form-control {
    border-radius: 6px;
    border: 1px solid #ddd;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 400;
    transition: border-color 0.2s;
    background-color: #fff !important;
    color: #333 !important;
}
.form-control:focus {
    border-color: #C24F4F;
    box-shadow: 0 0 0 3px rgba(194, 79, 79, 0.1);
}
/* SELECT DROPDOWN - Consistent with other form controls */
select.form-control,
.page-content select.form-control,
.page-card select.form-control {
    background-color: #fff !important;
    color: #333 !important;
    -webkit-text-fill-color: #333 !important;
    cursor: pointer;
    width: 100%;
    font-size: 14px;
    font-weight: 400;
    -webkit-appearance: menulist;
    -moz-appearance: menulist;
    appearance: menulist;
    opacity: 1 !important;
    padding: 8px 10px !important; /* Reduced padding for selects */
    height: auto !important;
}
select.form-control option,
.page-content select.form-control option,
.page-card select.form-control option {
    background-color: #fff !important;
    color: #333 !important;
    -webkit-text-fill-color: #333 !important;
    padding: 10px;
    font-weight: 400;
}

/* =====================================================
   CHECKBOXES & RADIO - Red theme styling
   ===================================================== */
input[type="checkbox"],
input[type="radio"] {
    accent-color: #C24F4F;
    width: 16px;
    height: 16px;
    cursor: pointer;
}
input[type="checkbox"]:focus,
input[type="radio"]:focus {
    outline: 2px solid rgba(194, 79, 79, 0.3);
    outline-offset: 2px;
}
/* Custom checkbox styling for better browser support */
.checkbox-red {
    position: relative;
    padding-left: 28px;
    cursor: pointer;
    user-select: none;
}
.checkbox-red input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}
.checkbox-red .checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 18px;
    width: 18px;
    background-color: #fff;
    border: 2px solid #ddd;
    border-radius: 3px;
    transition: all 0.2s;
}
.checkbox-red:hover input ~ .checkmark {
    border-color: #C24F4F;
}
.checkbox-red input:checked ~ .checkmark {
    background-color: #C24F4F;
    border-color: #C24F4F;
}
.checkbox-red .checkmark:after {
    content: "";
    position: absolute;
    display: none;
}
.checkbox-red input:checked ~ .checkmark:after {
    display: block;
}
.checkbox-red .checkmark:after {
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* =====================================================
   ALERTS - Unified alert styling
   ===================================================== */
.alert {
    border-radius: 8px;
    border: none;
    padding: 15px 20px;
    font-size: 14px;
}
.alert i { margin-right: 8px; }
.alert-success { background: #d4edda; color: #155724; }
.alert-danger { background: #f8d7da; color: #721c24; }
.alert-warning { background: #fff3cd; color: #856404; }
.alert-info { background: #d1ecf1; color: #0c5460; }

/* =====================================================
   API KEY DISPLAY
   ===================================================== */
.api-key-display { 
    font-family: 'Courier New', monospace; 
    font-size: 12px; 
    background: #f5f5f5; 
    padding: 8px 12px; 
    border-radius: 6px;
    color: #333;
}

/* =====================================================
   MISC HELPERS
   ===================================================== */
.text-muted { color: #888 !important; font-size: 12px; }
.text-small { font-size: 12px; }
.mb-0 { margin-bottom: 0 !important; }
.mb-10 { margin-bottom: 10px !important; }
.mb-20 { margin-bottom: 20px !important; }
.mb-30 { margin-bottom: 30px !important; }
.mt-10 { margin-top: 10px !important; }
.mt-20 { margin-top: 20px !important; }
.mt-30 { margin-top: 30px !important; }

/* =====================================================
   FOOTER
   ===================================================== */
footer {
    padding: 0 !important;
}
#mainFooter { 
    background: #f0f0f0; 
    padding: 30px 0 !important; 
    margin-top: 0; 
}
#footerRights { 
    background: #e8e8e8; 
    padding: 15px 0 !important; 
    margin-bottom: 0; 
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    .sidebar { position: relative; top: 0; }
    .stat-card h3 { font-size: 1.5rem; }
    .page-title { font-size: 20px; }
}

/* =====================================================
   MOBILE & ACCESSIBILITY
   ===================================================== */

/* Wide tables scroll inside their card instead of squeezing every column
   into a few characters (fixed table layout on a 390px screen). */
.table-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-card table {
    min-width: 640px;
}

/* Sidebar is a <details>: always open on desktop, one collapsible row on
   small screens (js/app.js). */
details.sidebar > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: default;
}
details.sidebar > summary::-webkit-details-marker {
    display: none;
}
.sidebar-current,
.sidebar-chevron {
    display: none;
}
@media (max-width: 991px) {
    .sidebar {
        margin-bottom: 20px;
    }
    details.sidebar > summary {
        cursor: pointer;
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: 0;
    }
    details.sidebar[open] > summary {
        margin-bottom: 15px;
    }
    .sidebar-current {
        display: inline;
        margin-left: auto;
        color: #333;
        font-weight: 600;
        text-transform: none;
        letter-spacing: 0;
    }
    .sidebar-chevron {
        display: inline-block;
        color: #333;
        transition: transform 0.2s;
    }
    details.sidebar[open] .sidebar-chevron {
        transform: rotate(180deg);
    }
}
@media (max-width: 767px) {
    /* Positioned next to the logo, it ended up behind the menu button. */
    .admin-badge-header {
        display: none;
    }
}

/* Contrast: white 10px text on the old badge colours was 2.2-3.8:1. */
.badge-status {
    font-size: 11px;
}
.badge-status.success, .badge-status.active, .badge-status.verified { background: #1e8449; }
.badge-status.warning, .badge-status.pending { background: #9a6400; }
.badge-status.danger, .badge-status.error, .badge-status.inactive { background: #c0392b; }
.badge-status.info { background: #2471a3; }
.badge-status.secondary, .badge-status.disabled { background: #6c7a7b; }
.text-muted {
    color: #6c6c6c !important;
}

/* Disabled/read-only fields must not look editable (.form-control forces a
   white background above). */
.form-control[disabled],
.form-control[readonly] {
    background-color: #f1f1f1 !important;
    color: #777 !important;
    cursor: not-allowed;
}

/* Visible keyboard focus (the theme removes outlines on links). */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
summary:focus-visible,
.form-control:focus-visible {
    outline: 2px solid #C24F4F !important;
    outline-offset: 2px;
}

/* Onboarding steps (check-email.php, dashboard quick start). */
.onboarding-steps {
    margin: 15px 0 0;
    padding-left: 20px;
    color: #555;
    line-height: 1.8;
}

/* Global modal: buttons get the focus ring too. */
#modalOverlay button:focus-visible {
    outline: 2px solid #333 !important;
    outline-offset: 2px;
}

/* Pagination (Layout::pagination) */
.pagination-nav {
    text-align: center;
    margin-top: 20px;
}

/* Content wider than a phone (tables outside .table-card, long code) scrolls
   inside its card instead of widening the whole page. */
.page-card {
    overflow-x: auto;
}
@media (max-width: 767px) {
    /* Filter forms use fixed inline widths (style="width: 300px"). */
    .page-card .form-control,
    .page-card .form-inline .form-group {
        width: 100% !important;
        max-width: 100%;
    }
    .page-card .form-inline .form-group {
        margin-bottom: 8px;
    }
}

/* ALTCHA bot check (src/Captcha.php): brand colour, full form width, and
   room reserved so the form does not jump when the widget script arrives. */
.captcha-field {
    --altcha-color-primary: #C24F4F;
    --altcha-max-width: 100%;
    min-height: 50px;
}
