/* ============================
   Responsive Styles
   ============================ */

/* Tablet */
@media (max-width: 1024px) {
    .analytics-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .top-bar {
        left: 0;
        display: flex;
    }

    .hamburger-btn {
        display: block;
    }

    .main-content {
        margin-left: 0;
        margin-top: var(--topbar-height);
    }

    /* Hide desktop user-info-bar on mobile (top-bar handles this) */
    .user-info-bar {
        display: none;
    }

    .dashboard-header-section {
        flex-direction: column;
        gap: 0.75rem;
    }

    .dashboard-header-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    .dashboard-header-actions .search-bar {
        flex: 1;
        min-width: 150px;
    }

    .view {
        padding: 1rem;
    }

    .view-header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-bar {
        max-width: 100%;
    }

    .view-actions {
        justify-content: flex-start;
        overflow-x: auto;
    }

    #view-attendance .attendance-view-actions {
        flex-direction: column;
        align-items: stretch;
        overflow-x: visible;
        gap: 0.55rem;
    }

    #view-attendance .attendance-action-row {
        width: 100%;
        display: flex;
        flex-wrap: nowrap;
    }

    #view-attendance .attendance-action-row .btn {
        flex: 1 1 0;
    }

    .user-email {
        display: none;
    }

    /* Show card view on mobile, hide table */
    .table-container {
        display: none;
    }

    .cards-container {
        display: grid !important;
    }

    /* Modal full page on mobile */
    .modal-content.modal-large {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        height: 100vh;
    }

    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .analytics-filters {
        flex-direction: column;
        width: 100%;
    }

    .analytics-filters input,
    .analytics-filters select {
        width: 100%;
    }

    .festivals-container {
        grid-template-columns: 1fr;
    }

    .settings-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        font-size: 0.8rem;
        padding: 0.6rem 0.75rem;
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        background: var(--white);
    }

    .attendance-date-section {
        flex-wrap: wrap;
    }

    .payment-tabs {
        overflow-x: auto;
    }

    /* Attendance mobile cards */
    .attendance-card {
        padding: 0.85rem;
        margin-bottom: 0.5rem;
    }

    .attendance-card .card-name {
        font-size: 1.02rem;
    }

    .attendance-card .card-payment {
        font-size: 0.74rem;
    }

    .attendance-card .att-card-actions.att-toggle-group {
        grid-template-columns: 1fr;
    }

    .attendance-card .att-toggle:not(:last-child) {
        border-right: none;
        border-bottom: 1px solid #E0E0E0;
    }

    /* Top bar compact */
    .top-bar {
        padding: 0 0.75rem;
    }

    #page-title {
        font-size: 1rem;
    }

    /* ===== Mobile Cards (shared base) ===== */
    .mobile-card {
        background: var(--white, #fff);
        border-radius: var(--radius, 8px);
        padding: 1rem;
        box-shadow: var(--shadow, 0 1px 4px rgba(0, 0, 0, 0.08));
        border: 1px solid var(--border-color, #e5e5e5);
        margin-bottom: 0.5rem;
    }

    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.4rem;
    }

    .mobile-card-name {
        font-weight: 700;
        font-size: 1rem;
        color: var(--text, #333);
    }

    .mobile-card-meta {
        font-size: 0.78rem;
        color: var(--text-secondary, #777);
        margin-bottom: 0.6rem;
    }

    .mobile-card-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.35rem 0.75rem;
        margin-bottom: 0.6rem;
    }

    .mobile-card-field {
        display: flex;
        flex-direction: column;
        font-size: 0.82rem;
    }

    .mobile-card-label {
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-secondary, #999);
        font-weight: 600;
    }

    .mobile-card-actions {
        display: flex;
        gap: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border-color, #eee);
    }

    .mobile-card-actions .btn-sm {
        flex: 1;
        font-size: 0.78rem;
        padding: 0.35rem 0.5rem;
    }

    .mobile-card-notes {
        font-size: 0.8rem;
        color: var(--text-secondary, #777);
        margin-top: 0.3rem;
        padding-top: 0.4rem;
        border-top: 1px dashed var(--border-color, #eee);
        word-break: break-word;
    }

    .mobile-card-ellipsis {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 170px;
        display: inline-block;
    }

    .mobile-card-diff {
        margin-top: 0.3rem;
    }

    .mobile-card-diff .mobile-card-field {
        margin-bottom: 0.25rem;
    }

    /* History card selected */
    .history-card-mobile.selected {
        border-color: var(--primary, #e67e22);
        box-shadow: 0 0 0 2px var(--primary-light, rgba(230, 126, 34, 0.25));
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .login-container {
        padding: 2rem 1.5rem;
    }

    .login-logo h1 {
        font-size: 1.3rem;
    }

    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .modal-content {
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
        height: 100vh;
    }

    .modal-fullscreen {
        width: 100vw;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .xlsx-mappings-grid {
        grid-template-columns: 1fr;
        max-height: 140px;
    }

    .xlsx-stats-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    #xlsx-preview-modal .modal-footer {
        flex-direction: column;
        gap: 0.75rem;
    }

    .xlsx-footer-right {
        width: 100%;
    }

    .xlsx-footer-right .btn {
        flex: 1;
    }

    .chart-card {
        padding: 1rem;
    }

    .chart-card h4 {
        font-size: 0.85rem;
    }

    /* User Stats responsive */
    .ustats-filters {
        flex-direction: column;
        gap: 0.5rem;
    }

    .ustats-filter-group select,
    .ustats-filter-group input {
        min-width: 100%;
    }

    .ustats-filter-actions {
        margin-left: 0;
        width: 100%;
    }

    .ustats-filter-actions .btn {
        flex: 1;
    }

    .ustats-table-wrapper {
        display: none;
    }

    .ustats-cards {
        display: block;
    }

    .ustats-summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .ustats-summary-card {
        padding: 0.85rem 0.6rem;
    }

    .ustats-summary-card .ustats-card-value {
        font-size: 1.3rem;
    }

    .ustats-chart-grid {
        grid-template-columns: 1fr;
    }

    .ustats-header-actions {
        flex-wrap: wrap;
    }
}

/* Print */
@media print {

    .sidebar,
    .top-bar,
    .hamburger-btn,
    .modal,
    .toast-container,
    .user-info-bar {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
        margin-top: 0;
    }

    .view {
        padding: 0;
    }

    .data-table {
        font-size: 0.75rem;
    }

    .btn,
    .view-actions {
        display: none !important;
    }
}