/* ============================================================
   RESPONSIVEADMIN.CSS — Global Responsive for ALL Admin Pages
   RASIN AYITI — Admin Panel
   Covers: sidebar, main-content, tables, cards, modals,
           forms, stats, grids, buttons, filters, etc.
   ============================================================ */

/* ============================================================
   TABLET — max-width: 1024px
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
        transition: transform 0.3s ease;
    }
    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        padding: 1.5rem !important;
        width: 100% !important;
    }

    .mobile-toggle {
        display: block !important;
    }

    .sidebar-overlay.active {
        display: block !important;
    }

    /* Header */
    .dashboard-header,
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .header-left {
        display: flex !important;
        align-items: center !important;
        gap: 1rem !important;
        width: 100%;
    }

    .header-right {
        width: 100%;
    }

    .header-right .btn-primary {
        width: 100%;
        justify-content: center;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    /* Dashboard Grid */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    /* Quick Actions */
    .quick-actions {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Tables */
    .table-card,
    .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 700px;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 1rem !important;
        font-size: 0.82rem !important;
    }

    /* Cards */
    .card-body {
        padding: 1.25rem !important;
    }

    /* Filters */
    .filters-bar,
    .filters-row {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .filter-select,
    .search-input {
        width: 100% !important;
        max-width: 100% !important;
        min-width: unset !important;
    }

    /* Form grid layouts */
    .form-grid,
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Modals */
    .modal-content,
    .modal-box {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        margin: 1rem !important;
    }

    /* Gallery / Photo grids */
    .gallery-grid,
    .photo-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Leaders grid */
    .leaders-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Email template grid */
    .template-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* Email stats row */
    .stats-row {
        flex-wrap: wrap !important;
    }
    .stats-row .stat-card {
        flex: 1 1 calc(50% - 0.5rem) !important;
        min-width: 140px !important;
    }

    /* Event / formation cards */
    .events-grid,
    .formations-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Maillots grid */
    .maillots-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ============================================================
   MOBILE — max-width: 768px
   ============================================================ */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    .main-content {
        padding: 1rem !important;
    }

    /* Sidebar */
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }

    /* Headers */
    .dashboard-header h1,
    .page-header h1,
    .page-title h1 {
        font-size: 1.3rem !important;
    }

    .dashboard-header p,
    .page-header p {
        font-size: 0.8rem;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    .stat-card {
        padding: 1rem !important;
    }

    .stat-value {
        font-size: 1.4rem !important;
    }

    .stat-label {
        font-size: 0.72rem !important;
    }

    .stat-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1rem !important;
    }

    /* Quick Actions */
    .quick-actions {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    .quick-action {
        padding: 1rem !important;
    }

    /* Buttons */
    .btn-primary,
    .btn-secondary {
        font-size: 0.85rem !important;
        padding: 0.7rem 1.25rem !important;
    }

    .form-actions {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .form-actions .btn-primary,
    .form-actions .btn-secondary {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Tables — full scroll */
    .table-card,
    .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px !important;
    }

    .data-table {
        min-width: 600px;
    }

    .data-table th {
        padding: 0.6rem 0.75rem !important;
        font-size: 0.7rem !important;
        white-space: nowrap;
    }

    .data-table td {
        padding: 0.75rem !important;
        font-size: 0.8rem !important;
    }

    .proof-img {
        width: 45px !important;
        height: 45px !important;
    }

    /* Cards */
    .card {
        border-radius: 14px !important;
    }

    .card-header {
        padding: 1rem !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
        align-items: flex-start !important;
    }

    .card-header h2 {
        font-size: 1rem !important;
    }

    .card-body {
        padding: 1rem !important;
    }

    /* Modals */
    .modal-overlay {
        padding: 0.5rem !important;
        align-items: flex-end !important;
    }

    .modal-content,
    .modal-box {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh !important;
        border-radius: 20px 20px 0 0 !important;
        margin: 0 !important;
    }

    .modal-header {
        padding: 1rem 1.25rem !important;
    }

    .modal-header h2,
    .modal-header h3 {
        font-size: 1rem !important;
    }

    .modal-body {
        padding: 1.25rem !important;
    }

    /* Gallery grids */
    .gallery-grid,
    .photo-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    /* Leaders grid */
    .leaders-grid {
        grid-template-columns: 1fr !important;
    }

    /* Formation / Event cards */
    .events-grid,
    .formations-grid {
        grid-template-columns: 1fr !important;
    }

    /* Maillots grid */
    .maillots-grid {
        grid-template-columns: 1fr !important;
    }

    /* Email template grid */
    .template-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .tpl-card {
        padding: 0.75rem !important;
    }

    .tpl-card .tpl-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.85rem !important;
    }

    .tpl-card strong {
        font-size: 0.75rem !important;
    }

    .tpl-card small {
        font-size: 0.65rem !important;
    }

    /* Stats Row (emails) */
    .stats-row {
        gap: 0.5rem !important;
    }
    .stats-row .stat-card {
        flex: 1 1 calc(50% - 0.25rem) !important;
        padding: 0.75rem !important;
        min-width: 0 !important;
    }
    .stats-row .stat-card i {
        width: 36px !important;
        height: 36px !important;
        font-size: 1rem !important;
    }
    .stats-row .stat-card span {
        font-size: 1.1rem !important;
    }
    .stats-row .stat-card small {
        font-size: 0.65rem !important;
    }

    /* Bulk bar */
    #bulkBar .card-body {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }

    /* Filters */
    .filters-row {
        flex-direction: column !important;
    }
    .filter-group {
        min-width: 100% !important;
    }

    /* Event form */
    .event-form .form-group {
        margin-bottom: 1rem !important;
    }

    /* Inscription cards */
    .inscription-card {
        flex-direction: column !important;
    }

    /* Form input full width */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    input[type="url"],
    input[type="file"],
    select,
    textarea {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Select inside table */
    .data-table select {
        width: auto !important;
        min-width: 100px;
        font-size: 0.75rem !important;
        padding: 0.3rem 0.5rem !important;
    }

    /* Badge */
    .badge,
    .status-badge,
    .source-badge {
        font-size: 0.68rem !important;
        padding: 0.2rem 0.5rem !important;
    }

    /* Quiz manager */
    .quiz-options-grid {
        grid-template-columns: 1fr !important;
    }

    /* Parametres leaders */
    .leader-card {
        flex-direction: column !important;
    }

    .flyer-preview {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Email preview */
    #emailPreviewFrame {
        padding: 0.75rem !important;
    }

    #emailPreviewFrame > div {
        padding: 16px 8px !important;
    }
}

/* ============================================================
   SMALL MOBILE — max-width: 480px
   ============================================================ */
@media (max-width: 480px) {
    .main-content {
        padding: 0.75rem !important;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
    }

    .stat-card {
        padding: 0.75rem !important;
        flex-direction: column !important;
        text-align: center !important;
        gap: 0.5rem !important;
    }

    .stat-value {
        font-size: 1.2rem !important;
    }

    /* Quick Actions */
    .quick-actions {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
    }

    .quick-action span {
        font-size: 0.75rem !important;
    }

    /* Dashboard header */
    .dashboard-header h1,
    .page-title h1 {
        font-size: 1.15rem !important;
    }

    /* Buttons compact */
    .btn-primary,
    .btn-secondary {
        font-size: 0.8rem !important;
        padding: 0.6rem 1rem !important;
    }

    .btn-primary span {
        display: none;
    }

    .header-right .btn-primary span {
        display: inline !important;
    }

    /* Tables even more compact */
    .data-table th {
        padding: 0.5rem 0.6rem !important;
        font-size: 0.65rem !important;
    }

    .data-table td {
        padding: 0.6rem !important;
        font-size: 0.75rem !important;
    }

    .proof-img {
        width: 35px !important;
        height: 35px !important;
    }

    /* Cards */
    .card {
        border-radius: 12px !important;
    }

    .card-body {
        padding: 0.75rem !important;
    }

    /* Modal full screen on small */
    .modal-content,
    .modal-box {
        max-height: 95vh !important;
        border-radius: 16px 16px 0 0 !important;
    }

    .modal-header h2,
    .modal-header h3 {
        font-size: 0.9rem !important;
    }

    .modal-body {
        padding: 1rem !important;
    }

    /* Photo grids */
    .gallery-grid,
    .photo-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
    }

    /* Template grid */
    .template-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    /* Stats row */
    .stats-row .stat-card {
        flex: 1 1 100% !important;
    }

    /* Form labels */
    .form-group label {
        font-size: 0.82rem !important;
    }

    /* Select & Input */
    .filter-select {
        font-size: 0.82rem !important;
    }

    .search-input {
        font-size: 0.82rem !important;
    }

    /* Sidebar */
    .sidebar {
        width: 260px;
    }

    .sidebar-header {
        gap: 0.75rem !important;
    }

    .sidebar-logo {
        width: 38px !important;
        height: 38px !important;
    }

    .sidebar-title {
        font-size: 0.95rem !important;
    }

    .nav-item {
        padding: 0.7rem 0.85rem !important;
        font-size: 0.85rem !important;
    }
}

/* ============================================================
   SIDEBAR OVERLAY — All breakpoints
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================================
   MOBILE TOGGLE — Hidden by default, shown on tablet/mobile
   ============================================================ */
.mobile-toggle {
    display: none;
    background: white;
    border: 2px solid #e2e8f0;
    padding: 0.6rem;
    border-radius: 10px;
    cursor: pointer;
    color: #1e293b;
    font-size: 1.2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

/* ============================================================
   TOUCH IMPROVEMENTS
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
    .nav-item {
        padding: 0.9rem 1rem !important;
        min-height: 44px;
    }

    .btn-action {
        min-width: 36px !important;
        min-height: 36px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .data-table input[type="checkbox"] {
        width: 20px !important;
        height: 20px !important;
    }

    select {
        min-height: 44px;
    }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .sidebar,
    .sidebar-overlay,
    .mobile-toggle,
    .header-right,
    .form-actions,
    .modal-overlay,
    #bulkBar {
        display: none !important;
    }

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

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }

    .data-table {
        min-width: unset !important;
    }
}
