/* Enhanced Responsive Design for GCF Dashboards */

/* Mobile-First Base Improvements */
* {
    box-sizing: border-box;
}

/* Enhanced Touch Targets */
.btn, button, input[type="submit"], input[type="button"], .nav-item {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

/* Improved Mobile Navigation */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 10000;
    background: var(--forest-green);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    font-size: 18px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    z-index: 9999;
    padding: 0 60px 0 15px;
    align-items: center;
    justify-content: space-between;
}

.mobile-header h1 {
    font-size: 18px;
    margin: 0;
    color: var(--forest-green);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Enhanced Mobile Tables */
.table-mobile-card {
    display: none;
}

.table-mobile-row {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 15px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-mobile-row .mobile-header {
    font-weight: bold;
    color: var(--forest-green);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f3f4f6;
}

.table-mobile-row .mobile-field {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f9fafb;
}

.table-mobile-row .mobile-field:last-child {
    border-bottom: none;
}

.table-mobile-row .field-label {
    font-weight: 600;
    color: #6b7280;
    font-size: 14px;
}

.table-mobile-row .field-value {
    text-align: right;
    font-size: 14px;
    color: #1f2937;
}

.table-mobile-row .mobile-actions {
    margin-top: 15px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.table-mobile-row .mobile-actions .btn {
    flex: 1;
    min-width: auto;
    font-size: 14px;
}

/* Responsive Breakpoints */
/* Extra Small Mobile (320px - 480px) */
@media screen and (max-width: 480px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .mobile-header {
        display: flex;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 9998;
    }
    
    .content-area {
        margin-left: 0;
        padding: 80px 15px 20px;
        min-height: 100vh;
    }
    
    /* Hide desktop tables on mobile */
    .table-responsive table {
        display: none;
    }
    
    /* Show mobile card layout */
    .table-mobile-card {
        display: block;
    }
    
    /* Stats cards mobile */
    .stats {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 20px 15px;
        min-height: auto;
    }
    
    .stat-number {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    /* Form improvements */
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-group label {
        font-size: 14px;
        margin-bottom: 5px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px;
    }
    
    /* Modal improvements */
    .modal-content {
        margin: 15px;
        max-width: calc(100% - 30px);
        max-height: calc(100vh - 30px);
        overflow-y: auto;
    }
    
    /* Button groups */
    .btn-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-group .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Small Mobile (481px - 600px) */
@media screen and (min-width: 481px) and (max-width: 600px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .mobile-header {
        display: flex;
    }
    
    .content-area {
        margin-left: 0;
        padding: 80px 20px 20px;
    }
    
    .stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .table-mobile-card {
        display: block;
    }
    
    .table-responsive table {
        display: none;
    }
}

/* Tablet (601px - 768px) */
@media screen and (min-width: 601px) and (max-width: 768px) {
    .content-area {
        padding: 20px 25px;
    }
    
    .stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .stat-card {
        padding: 25px 20px;
    }
    
    /* Keep tables but improve them */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-responsive table {
        min-width: 600px;
        font-size: 13px;
    }
    
    .table-responsive th,
    .table-responsive td {
        padding: 8px 10px;
    }
}

/* Large Tablet (769px - 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
    
    .content-area {
        padding: 25px 30px;
    }
    
    .table-responsive table {
        font-size: 14px;
    }
}

/* Desktop optimizations */
@media screen and (min-width: 1025px) {
    .mobile-menu-toggle,
    .mobile-header {
        display: none;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .nav-item:hover {
        transform: none;
    }
    
    .btn:active,
    .nav-item:active {
        transform: scale(0.98);
    }
    
    /* Increase spacing between clickable elements */
    .table-actions {
        gap: 8px;
    }
    
    .btn {
        margin: 2px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .stat-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Landscape mobile optimizations */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .mobile-header {
        height: 50px;
    }
    
    .content-area {
        padding-top: 70px;
    }
    
    .modal-content {
        max-height: 90vh;
        margin: 5px;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .mobile-header,
    .btn,
    .modal {
        display: none !important;
    }
    
    .content-area {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .table-responsive {
        overflow: visible !important;
    }
    
    .table-mobile-card {
        page-break-inside: avoid;
    }
}
