/* ============================================================================
   RESPONSIVE STYLES - COMPLETE MOBILE OPTIMIZATION
   ============================================================================
   This stylesheet provides mobile-friendly layouts for both user-facing pages
   and admin pages of the Wargame system.
   ============================================================================ */

/* ============================================================================
   THE PARTICIPANT PALETTE (row 47) - THE FALLBACK HALF
   ============================================================================
   Every colour a participant sees has one name, and the value behind that name is decided in
   ONE place: wg_ui_palette_standard() in db.php (a site can override any of them on the Styles
   tab, which is the same function with the stored values merged on top). The block below is the
   mirror of that array, written as CSS custom properties, for two jobs:

     - it is the fallback of every var() the participant pages paint with, so a page that never
       prints the database's own :root block still looks right;
     - it names the roles in the stylesheet, so "which grey is the small print?" is answered here
       rather than by grepping for #666 across twenty files.

   CHANGE A COLOUR IN db.php, NOT HERE. This block is compared to wg_ui_palette_standard() by
   _probe_palette.php, which fails when the two disagree - a stylesheet that has quietly drifted
   from the value the mail carries is exactly the bug row 47 was opened for.

   The names are prefixed --wg-page- rather than --wg- so they cannot collide with the admin
   panel's --wg-accent and friends in admin.css: responsive.css is loaded on admin pages too
   (admin_user_radar.php among them), and two definitions of --wg-accent on one page is a
   restyle nobody asked for.
   ============================================================================ */
:root {
    --wg-page-bg: #f5f5f5;
    --wg-page-surface: #ffffff;
    --wg-page-ink: #333333;
    --wg-page-ink-soft: #555555;
    --wg-page-ink-muted: #666666;
    --wg-page-ink-faint: #999999;
    --wg-page-line: #dddddd;
    --wg-page-line-soft: #eeeeee;
    --wg-page-panel: #f8f9fa;
    --wg-page-panel-deep: #e9ecef;
    --wg-page-neutral: #6c757d;
    --wg-page-neutral-dark: #5a6268;
    --wg-page-neutral-disabled: #adb5bd;
    --wg-page-accent: #007bff;
    --wg-page-accent-dark: #0056b3;
    --wg-page-accent-soft: #e7f3ff;
    --wg-page-info-bg: #cce5ff;
    --wg-page-info-ink: #004085;
    --wg-page-good: #28a745;
    --wg-page-good-dark: #218838;
    --wg-page-good-bg: #d4edda;
    --wg-page-good-line: #c3e6cb;
    --wg-page-good-ink: #155724;
    --wg-page-warn: #856404;
    --wg-page-warn-bg: #fff3cd;
    --wg-page-warn-line: #ffeeba;
    --wg-page-warn-bright: #ffc107;
    --wg-page-bad: #dc3545;
    --wg-page-bad-dark: #c82333;
    --wg-page-danger-line: #f5c6cb;
    --wg-page-danger-soft: #fffafb;
    --wg-page-danger-ink: #d9534f;
    --wg-page-danger-bg: #f8d7da;
    --wg-page-danger-strong-ink: #721c24;
}

/* ============================================================================
   BASE MOBILE OPTIMIZATIONS
   ============================================================================ */

* {
    box-sizing: border-box;
}

body {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    word-wrap: break-word;
}

/* Ensure containers don't overflow on small screens */
.container, .box, .form-container {
    max-width: 100%;
    margin-left: 10px;
    margin-right: 10px;
    padding: 15px;
}

/* ============================================================================
   USER-FACING PAGES - Rating Buttons
   ============================================================================ */

@media (max-width: 600px) {
    .rating-group {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .rating-option label {
        padding: 15px !important;
        font-size: 16px !important;
    }
}

/* ============================================================================
   USER-FACING PAGES - Forms
   ============================================================================ */

@media (max-width: 600px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        padding: 12px !important;
    }
    
    button,
    .submit-btn,
    .btn {
        width: 100%;
        padding: 14px !important;
        font-size: 16px !important;
    }
    
    /* Choice text box on confirm_decision.php */
    .choice-text {
        font-size: 18px !important;
        padding: 15px !important;
    }
}

/* ============================================================================
   USER-FACING PAGES - Typography
   ============================================================================ */

@media (max-width: 600px) {
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    h1 {
        font-size: 24px;
    }
    
    h2 {
        font-size: 20px;
    }
    
    p {
        font-size: 16px;
        line-height: 1.6;
    }
}

/* ============================================================================
   USER-FACING PAGES - Layout Adjustments
   ============================================================================ */

@media (max-width: 600px) {
    /* Remove large margins on mobile */
    body {
        margin: 10px !important;
    }
    
    /* Stack form rows vertically */
    .form-row {
        flex-direction: column !important;
    }
    
    /* Make choice buttons stack on pilot_feedback.php */
    .choice-buttons {
        flex-direction: column !important;
    }
    
    .choice-btn {
        width: 100%;
        margin-bottom: 10px;
    }
}

/* ============================================================================
   USER-FACING PAGES - Intro Boxes
   ============================================================================ */

@media (max-width: 600px) {
    .intro, .info-box {
        padding: 12px !important;
        font-size: 15px !important;
    }
}

/* ============================================================================
   ADMIN PAGES - Header Navigation
   ============================================================================ */

@media (max-width: 768px) {
    .header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px;
    }
    
    .header h1 {
        font-size: 22px;
    }
    
    .header > div {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }
    
    .header .btn {
        flex: 1 1 auto;
        text-align: center;
        white-space: nowrap;
        padding: 8px 12px !important;
        font-size: 13px !important;
    }
}

/* ============================================================================
   ADMIN DASHBOARD - Stats and Cards
   ============================================================================ */

@media (max-width: 768px) {
    .stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .admin-grid {
        grid-template-columns: 1fr !important;
    }
    
    .stat-card {
        padding: 15px !important;
    }
    
    .stat-number {
        font-size: 28px !important;
    }
    
    .admin-card {
        padding: 20px !important;
    }
}

@media (max-width: 400px) {
    .stats {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================================================
   ADMIN TABLES - Mobile-Friendly Horizontal Scroll
   ============================================================================ */

@media (max-width: 768px) {
    /* Make tables scrollable horizontally with visual hint */
    div[style*="overflow-x: auto"] {
        -webkit-overflow-scrolling: touch;
        position: relative;
    }
    
    /* Smaller font and padding for tables on mobile */
    table {
        font-size: 12px !important;
        min-width: 800px; /* Forces horizontal scroll */
    }
    
    table th,
    table td {
        padding: 6px 8px !important;
        white-space: nowrap;
    }
    
    /* Add scroll hint indicator */
    div[style*="overflow-x: auto"]::after {
        content: "← Scroll →";
        display: block;
        text-align: center;
        font-size: 12px;
        color: #999;
        padding: 8px;
        background: #f9f9f9;
        border-radius: 4px;
        margin-top: 5px;
    }
    
    /* Hide less important columns on mobile - show essential info only */
    .hide-mobile {
        display: none !important;
    }
    
    /* Show email in a tooltip or make name clickable */
    table td:nth-child(2) {
        font-weight: bold;
    }
}

/* ============================================================================
   ADMIN FORMS - Stack Fields on Mobile
   ============================================================================ */

@media (max-width: 768px) {
    .add-form {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .add-form input {
        width: 100% !important;
        margin-right: 0 !important;
    }
    
    .form-container {
        padding: 15px !important;
    }
    
    fieldset {
        padding: 10px !important;
    }
    
 legend {
     font-size: 14px !important;
 }
}

}

/* ============================================================================
   ADMIN CHECKLIST - Better Mobile Layout
   ============================================================================ */

@media (max-width: 768px) {
    .category {
        margin-bottom: 15px !important;
    }
    
    .category-header {
        font-size: 14px !important;
        padding: 12px !important;
    }
    
    .checklist-item {
        padding: 12px !important;
    }
    
    .checklist-item input[type="checkbox"] {
        width: 24px !important;
        height: 24px !important;
    }
    
    .checklist-item-label {
        font-size: 14px !important;
    }
}

/* ============================================================================
   ADMIN FEEDBACK - Stats Summary Mobile
   ============================================================================ */

@media (max-width: 768px) {
    .stats-summary {
        padding: 15px !important;
    }
    
    .avg-ratings {
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    .avg-number {
        font-size: 28px !important;
    }
}

/* ============================================================================
   ADMIN DEBUG - Status Box Mobile
   ============================================================================ */

@media (max-width: 768px) {
    .status-box {
        padding: 20px !important;
    }
    
    .status-icon {
        font-size: 36px !important;
    }
    
    .status-text {
        font-size: 20px !important;
    }
    
    .toggle-btn {
        width: 100%;
        padding: 15px 20px !important;
    }
}

/* ============================================================================
   IMPORT PAGE - Better Mobile Instructions
   ============================================================================ */

@media (max-width: 768px) {
    .step {
        padding: 12px !important;
    }
    
    .step-number {
        width: 26px !important;
        height: 26px !important;
        line-height: 26px !important;
        font-size: 14px !important;
    }
    
    pre, .example {
        font-size: 12px !important;
        overflow-x: auto;
    }
    
.download-btn, .submit-btn {
    width: 100%;
    text-align: center;
}
}

/* (Global Environment Indicator styles have been moved to admin_auth.php for better reliability) */

/* ============================================================================
ADMIN USERS - Compact Badges & Header Filters
============================================================================ */
.compact-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
}
.compact-badge:hover { opacity: 0.8; }
.badge-trial { background: #fff3cd; color: #856404; }
.badge-subscribed { background: #d4edda; color: #155724; }
.badge-email { background: #cce5ff; color: #004085; }
.badge-browser { background: #e2e3ff; color: #383d6e; }

.header-filter-select {
    font-size: 10px;
    width: 100%;
    margin-top: 4px;
    padding: 2px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
}
.global-search-box {
    padding: 8px 12px;
    border: 2px solid #007bff;
    border-radius: 6px;
    font-size: 14px;
    width: 250px;
    max-width: 100%;
}

/* ============================================================================
ADMIN USERS - COMPACT BADGES, PILLS & FILTERS (Moved from admin_users.php)
============================================================================ */
.pill-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 24px; height: 24px; padding: 0 6px;
    border-radius: 12px; font-size: 12px; font-weight: bold;
    cursor: default; transition: transform 0.1s;
}
.pill-badge:hover { transform: scale(1.1); }
.pill-trial { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.pill-subscribed { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.pill-email { background: #cce5ff; color: #004085; border: 1px solid #b8daff; }
.pill-browser { background: #e2e3ff; color: #383d6e; border: 1px solid #d4d6ff; }
.pill-clickable { cursor: pointer; }
.pill-clickable:hover { opacity: 0.8; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.pill-disabled { opacity: 0.4; cursor: not-allowed !important; }

.finished-badge { display: inline-block; padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: bold; }
.badge-done { background: #d4edda; color: #155724; }
.badge-active { background: #cce5ff; color: #004085; }
.badge-erased { background: #e2e3e5; color: #383d41; }

.last-interaction { font-size: 12px; color: #666; white-space: nowrap; }
.last-interaction.never { color: #999; font-style: italic; }

.row-testuser { background-color: #fff9e6 !important; }
.row-testuser:hover { background-color: #fff3cd !important; }
.row-erased { background-color: #f8f9fa !important; opacity: 0.7; }
.row-erased:hover { background-color: #e9ecef !important; opacity: 1; }

.search-box { padding: 10px 15px; border: 2px solid #007bff; border-radius: 6px; font-size: 14px; width: 250px; max-width: 100%; }
.search-box:focus { outline: none; border-color: #0056b3; box-shadow: 0 0 0 3px rgba(0,123,255,0.1); }

.filter-bar {
    display: flex; gap: 8px; margin-bottom: 15px; flex-wrap: wrap; align-items: center;
    background: #f8f9fa; padding: 10px; border-radius: 6px; border: 1px solid #dee2e6;
}
.filter-bar label { font-weight:bold; font-size:13px; color:#333; margin-right: 4px; }
.filter-bar select { padding: 6px; border-radius: 4px; border: 1px solid #ccc; font-size: 13px; }

.kebab-dropdown { display: none; position: absolute; right: 0; top: 100%; background: white; border: 1px solid #ddd; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.15); z-index: 1000; min-width: 180px; text-align: left; }
.kebab-dropdown.show { display: block; }
.kebab-item:hover { background-color: #f8f9fa; }

.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.5); }
.modal-content { background-color: #fefefe; margin: 5% auto; padding: 25px; border: 1px solid #888; width: 90%; max-width: 600px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.modal-close { color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer; }
.modal-close:hover { color: #000; }

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: bold; font-size: 14px; }
.form-control { width: 100%; padding: 8px; box-sizing: border-box; border: 1px solid #ccc; border-radius: 4px; }
.checkbox-group { display: flex; gap: 15px; flex-wrap: wrap; margin-top: 10px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: bold; font-size: 13px; padding: 8px 12px; border-radius: 4px; border: 1px solid #ddd; }

/* Stuck User Traffic Lights */
.stuck-indicator { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.stuck-red { background: #dc3545; box-shadow: 0 0 4px rgba(220,53,69,0.5); }
.stuck-yellow { background: #ffc107; box-shadow: 0 0 4px rgba(255,193,7,0.5); }
.stuck-green { background: #28a745; }
.stuck-grey { background: #ccc; }

/* #311 - the clickable variable chips, the note that replaces a guess, and the Jodit toolbar
   button; row 69 adds the sample chip, which wears the same clothes because it is clicked the
   same way. Every rule is scoped to its own .wg-var-/wg-snippet class: responsive.css is also
   loaded inside the participant preview iframe, so a rule that reached a bare <code> or <button>
   would style text the participant reads. */
.wg-var-chip, .wg-snippet-chip { display: inline-block; margin: 2px 1px; padding: 1px 4px; font: inherit; cursor: pointer;
    background: #fff; border: 1px solid #99c9ef; border-radius: 4px; color: inherit; line-height: 1.4; }
.wg-var-chip:hover, .wg-snippet-chip:hover { background: #d1e7fd; border-color: #0056b3; }
.wg-var-chip:focus, .wg-snippet-chip:focus { outline: 2px solid #0056b3; outline-offset: 1px; }
.wg-var-chip code { background: transparent; padding: 0; }
.wg-var-card .wg-var-chip, .wg-var-card .wg-snippet-chip { border-color: #6cb2eb; }
.wg-var-note { display: block; margin-top: 6px; padding: 4px 8px; border-radius: 4px;
    background: #fff3cd; color: #856404; border: 1px solid #ffeeba; font-size: 13px; }
.wg-var-btn { margin-left: 4px; padding: 2px 7px; font: 12px/1.4 monospace; cursor: pointer;
    background: transparent; border: 1px solid transparent; border-radius: 3px; color: #444; }
.wg-var-btn:hover { background: #e9ecef; border-color: #ced4da; }
.wg-var-popup { z-index: 1200; max-width: 460px; background: #fff; border: 1px solid #cce5ff;
    border-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.18); padding: 8px; font-size: 13px; }
