/* ==========================================
   MOBILE UI REVAMP - Enhanced Touch Targets & Layouts
   Date: 2026-02-09
   ========================================== */

/* ===================
   IMPROVED BUTTON SIZES FOR TOUCH
   Apple HIG: Minimum 44px x 44px touch targets
   =================== */

/* Enhanced Button Sizes - Mobile First */
.btn-icon {
    /* Increase base size for better touch targets */
    padding: var(--space-3) var(--space-4); /* 0.75rem x 1rem = 12px x 16px */
    font-size: 0.9rem; /* Increased from 0.8rem */
    min-height: 44px; /* Apple HIG minimum */
    min-width: 80px; /* Ensure readable */
}

.btn-icon svg {
    width: 18px; /* Increased from 16px */
    height: 18px;
}

/* Page Header Action Buttons - Better Touch Targets */
.page-header-actions .btn-icon {
    min-height: 44px;
    padding: var(--space-3) var(--space-5);
    font-size: 0.9rem;
    flex: 0 0 auto; /* Fixed size - don't grow or shrink */
    white-space: nowrap; /* Keep text on one line */
}

/* Card Actions - Larger Touch Targets */
.card-actions {
    gap: var(--space-3); /* Increased gap */
    padding: 0 var(--space-3) var(--space-3);
}

.card-actions .btn-icon {
    min-height: 44px;
    padding: var(--space-3) var(--space-4);
    font-size: 0.9rem;
    flex: 1;
}

.card-actions .btn-icon svg {
    width: 18px;
    height: 18px;
}

/* Survey Edit/Delete Buttons - Match Good Size */
.library-survey-actions .btn-icon {
    min-height: 44px; /* Match survey edit button size */
    padding: var(--space-3) var(--space-4);
    font-size: 0.9rem;
}

.library-survey-actions .btn-icon svg {
    width: 18px;
    height: 18px;
}

/* ===================
   MOBILE RESPONSIVE LAYOUTS
   =================== */

/* Mobile: 768px and below */
@media (max-width: 768px) {

    /* CENTER ALIGN STATS ON MOBILE */
    .stats-grid,
    .stats-grid-3 {
        grid-template-columns: 1fr;
        gap: var(--space-4);
        text-align: center;
    }

    .stats-widget {
        flex-direction: column;
        text-align: center;
        padding: var(--space-5);
    }

    .stats-content {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .stats-icon {
        margin: 0 auto;
    }

    /* LARGER BUTTONS ON MOBILE */
    .btn-icon {
        padding: var(--space-3) var(--space-5);
        font-size: 0.95rem;
        min-height: 48px; /* Larger on mobile */
    }

    .btn-icon svg {
        width: 20px;
        height: 20px;
    }

    /* Card Actions Full Width */
    .card-actions {
        flex-direction: column;
        gap: var(--space-2);
    }

    .card-actions .btn-icon {
        width: 100%;
        min-height: 48px;
        padding: var(--space-3) var(--space-4);
    }

    /* SURVEY CARD MOBILE LAYOUT */
    .library-survey-card {
        padding: var(--space-4);
    }

    .library-survey-header {
        flex-direction: column;
        gap: var(--space-3);
    }

    .library-survey-title {
        font-size: 1rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        line-height: 1.4;
    }

    .library-survey-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }

    /* Stack Survey Actions Vertically */
    .library-survey-actions {
        width: 100%;
        flex-direction: column;
        gap: var(--space-2);
        margin-top: var(--space-3);
    }

    .library-survey-actions .btn-icon {
        width: 100%;
        justify-content: center;
        min-height: 48px;
        padding: var(--space-3) var(--space-4);
        font-size: 0.95rem;
    }

    /* Page Header Actions Stack on Mobile */
    .page-header-actions {
        width: 100%;
        flex-direction: column;
        gap: var(--space-2);
    }

    .page-header-actions .btn-icon {
        width: 100%;
        min-height: 48px;
        justify-content: center;
    }

    /* Toolbar Actions Better Spacing */
    .toolbar-actions {
        width: 100%;
        flex-direction: column;
        gap: var(--space-2);
    }

    .toolbar-actions .select {
        width: 100%;
        min-height: 44px;
        font-size: 0.9rem;
        padding: var(--space-3) var(--space-4);
    }

    /* Bulk Actions Stack */
    #bulk-actions,
    #rc-bulk-actions {
        flex-direction: column !important;
        width: 100%;
        gap: var(--space-2) !important;
    }

    #bulk-actions button,
    #rc-bulk-actions button {
        width: 100% !important;
        min-height: 48px !important;
        padding: var(--space-3) var(--space-4) !important;
        font-size: 0.95rem !important;
    }

    /* Toolbar Row Mobile Layout */
    .toolbar-row {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-row .search-box {
        width: 100%;
        margin-bottom: var(--space-2);
    }

    .toolbar-row .toolbar-actions {
        flex-direction: column;
        width: 100%;
        gap: var(--space-2);
    }

    .toolbar-row .toolbar-actions select {
        width: 100%;
    }
}

/* Small Mobile: 640px and below */
@media (max-width: 640px) {

    /* Even Larger Touch Targets */
    .btn-icon {
        min-height: 48px;
        padding: var(--space-3) var(--space-4);
        font-size: 1rem;
    }

    .btn-icon svg {
        width: 20px;
        height: 20px;
    }

    /* Survey Title - Better Text Wrapping */
    .library-survey-title {
        font-size: 0.95rem;
        line-height: 1.5;
        max-width: 100%;
    }

    /* Survey Card Compact */
    .library-survey-card {
        padding: var(--space-3);
    }

    .library-survey-info {
        width: 100%;
    }

    /* Full Width Buttons */
    .page-header-actions .btn-icon,
    .card-actions .btn-icon,
    .library-survey-actions .btn-icon {
        width: 100%;
        min-height: 50px; /* Extra large for small screens */
        font-size: 1rem;
    }

    /* Tab Navigation Better Touch */
    .tab-btn {
        min-height: 48px;
        padding: var(--space-3) var(--space-4);
        font-size: 0.9rem;
    }

    .tab-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* Extra Small Mobile: 480px and below */
@media (max-width: 480px) {

    /* Maintain text visibility on small screens */
    .page-header-actions .btn-icon span,
    .card-actions .btn-icon span,
    .library-survey-actions .btn-icon span {
        display: inline; /* Keep text visible */
        font-size: 0.9rem;
    }

    /* Compact but readable */
    .btn-icon {
        min-height: 48px;
        padding: var(--space-3);
        gap: var(--space-2);
    }

    /* Survey Meta Compact */
    .library-survey-meta {
        font-size: 0.8rem;
    }

    /* Stats Widget Compact */
    .stats-widget {
        padding: var(--space-4);
    }

    .stats-value {
        font-size: 1.75rem; /* Slightly smaller on very small screens */
    }

    .stats-label {
        font-size: 0.85rem;
    }
}

/* ===================
   SURVEY CARD FIX - PREVENT OVERFLOW
   =================== */

/* Prevent long survey names from breaking layout */
.library-survey-card {
    overflow: hidden;
}

.library-survey-info {
    overflow: hidden;
}

.library-survey-title {
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
}

/* Two-row layout for survey cards on tablets */
@media (min-width: 640px) and (max-width: 1023px) {
    .library-survey-header {
        flex-wrap: wrap;
    }

    .library-survey-info {
        flex: 1 1 100%;
        width: 100%;
    }

    .library-survey-actions {
        flex: 1 1 100%;
        width: 100%;
        justify-content: flex-start;
        margin-top: var(--space-3);
    }

    .library-survey-actions .btn-icon {
        flex: 0 1 auto;
        min-width: 120px;
    }
}

/* ===================
   IMPROVED TOUCH FEEDBACK
   =================== */

/* Better visual feedback for touch */
.btn-icon:active {
    transform: scale(0.98) translateY(1px);
    transition: transform 0.1s ease;
}

.card-preview:active {
    transform: scale(0.99);
    transition: transform 0.1s ease;
}

/* Increase tap highlight for better UX */
.btn-icon,
.card-preview,
.library-survey-card,
.stats-widget {
    -webkit-tap-highlight-color: rgba(133, 138, 107, 0.2);
}

/* ===================
   ACCESSIBILITY IMPROVEMENTS
   =================== */

/* Ensure minimum text size for readability */
@media (max-width: 640px) {
    body {
        font-size: 16px; /* Prevent iOS zoom on input focus */
    }

    input,
    select,
    textarea {
        font-size: 16px; /* Prevent iOS zoom */
    }
}

/* Better focus indicators for keyboard navigation */
.btn-icon:focus-visible,
button:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

/* ===================
   PERFORMANCE SUMMARY CENTER ALIGNMENT
   =================== */

/* Dashboard Stats - Center on Mobile */
@media (max-width: 768px) {
    .performance-summary,
    .analytics-summary,
    .dashboard-stats {
        text-align: center;
    }

    .performance-summary .stats-grid,
    .analytics-summary .stats-grid,
    .dashboard-stats .stats-grid {
        grid-template-columns: 1fr;
        justify-items: center;
    }
}

/* ===================
   SELECT DROPDOWN IMPROVEMENTS
   =================== */

@media (max-width: 640px) {
    .select,
    select {
        min-height: 44px;
        padding: var(--space-3) var(--space-4);
        font-size: 1rem;
        width: 100%;
    }
}
