/**
 * Mobile Styles - Responsive Design
 * Breakpoints:
 * - Mobile: 0-480px
 * - Tablet: 481px-768px
 * - Desktop: 769px+
 */

/* ============================================
   BASE MOBILE STYLES (0-768px)
   ============================================ */

/* Hide desktop navigation on mobile */
@media (max-width: 768px) {
    .nav {
        display: none;
    }
    
    .nav.mobile-open {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: var(--card-bg);
        flex-direction: column;
        z-index: 1000;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
        overflow-y: auto;
        animation: slideIn 0.3s ease-out;
    }
    
    @keyframes slideIn {
        from {
            transform: translateX(-100%);
        }
        to {
            transform: translateX(0);
        }
    }
    
    /* Nav header */
    .nav-header {
        display: none;
        padding: 1.5rem 1.5rem 1rem;
        border-bottom: 1px solid var(--border-color);
        align-items: center;
        justify-content: space-between;
    }
    
    .nav.mobile-open .nav-header {
        display: flex;
    }
    
    .nav-title {
        margin: 0;
        font-size: 1.25rem;
        font-weight: 600;
        color: var(--text-primary);
    }
    
    .nav-close {
        background: none;
        border: none;
        font-size: 2rem;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 0;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        transition: background 0.2s;
    }
    
    .nav-close:active {
        background: rgba(0, 0, 0, 0.05);
    }
    
    .nav-list {
        flex-direction: column;
        padding: 0.5rem 0;
    }
    
    .nav-item {
        width: 100%;
    }
    
    .nav-link {
        padding: 0.875rem 1.5rem;
        display: flex;
        align-items: center;
        gap: 1rem;
        border-left: 3px solid transparent;
        transition: all 0.2s ease;
        margin: 0 0.5rem;
        border-radius: 8px;
        border-left: none;
    }
    
    .nav-link:active {
        background: rgba(0, 0, 0, 0.03);
    }
    
    .nav-link.active {
        background: rgba(37, 99, 235, 0.08);
        color: var(--primary-color);
        font-weight: 600;
    }
    
    /* Hide icons in mobile menu */
    .nav-icon {
        display: none;
    }
    
    .nav-text {
        font-size: 1rem;
        font-weight: 500;
    }
}

/* Mobile menu button - integrated in header */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.75rem;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.mobile-menu-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }
}

/* Mobile overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

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

/* ============================================
   TOUCH OPTIMIZATION
   ============================================ */

@media (max-width: 768px) {
    /* Minimum touch target size: 44x44px */
    .btn,
    button,
    .chip,
    .nav-link,
    .status-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Larger tap targets for buttons */
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    .btn-sm {
        padding: 0.625rem 1rem;
        min-height: 40px;
    }
    
    /* Form inputs */
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
        padding: 0.75rem;
    }
    
    /* Chips/Tags */
    .chip {
        padding: 0.625rem 1rem;
        font-size: 0.9rem;
    }
}

/* ============================================
   CONTAINER & LAYOUT
   ============================================ */

@media (max-width: 768px) {
    .container {
        padding: 1rem;
        max-width: 100%;
    }
    
    /* Modern Mobile Header */
    .header {
        padding: 0.75rem 1rem;
        margin-left: 0;
    }
    
    .header-content {
        align-items: center;
    }
    
    .logo {
        display: flex;
        align-items: center;
        gap: 0;
    }
    
    .logo-text {
        font-size: 1.1rem;
        font-weight: 600;
    }
    
    /* Hide user name on mobile */
    .user-name {
        display: none;
    }
    
    /* Logout button as icon only */
    .btn-logout {
        min-width: 44px;
        padding: 0.625rem;
        border: none;
        background: none;
        color: var(--text-primary);
    }
    
    .btn-logout:hover,
    .btn-logout:active {
        background: rgba(0, 0, 0, 0.05);
    }
    
    .logout-text {
        display: none;
    }
    
    .logout-icon {
        display: inline-block;
        font-size: 1.5rem;
        font-weight: bold;
    }
    
    /* Cards */
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    /* Grids become single column */
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Flex gaps */
    .flex {
        gap: 0.5rem;
        flex-wrap: wrap;
    }
}

/* Desktop - show text, hide icon */
@media (min-width: 769px) {
    .logout-icon {
        display: none;
    }
    
    .logout-text {
        display: inline;
    }
}

/* ============================================
   TABLES TO CARDS
   ============================================ */

@media (max-width: 768px) {
    /* Hide table on mobile */
    .table {
        display: none;
    }
    
    /* Show mobile cards instead */
    .mobile-cards {
        display: block;
    }
    
    .mobile-card {
        background: var(--card-bg);
        border-radius: 8px;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    .mobile-card-header {
        font-size: 1.1rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
        color: var(--text-primary);
    }
    
    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--border-color);
    }
    
    .mobile-card-row:last-child {
        border-bottom: none;
    }
    
    .mobile-card-label {
        color: var(--text-secondary);
        font-size: 0.875rem;
    }
    
    .mobile-card-value {
        color: var(--text-primary);
        font-weight: 500;
        text-align: right;
    }
    
    .mobile-card-actions {
        margin-top: 1rem;
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
}

/* Desktop: hide mobile cards */
@media (min-width: 769px) {
    .mobile-cards {
        display: none;
    }
    
    .mobile-menu-btn {
        display: none;
    }
}

/* Mobile: hide desktop-only elements */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

/* ============================================
   MODALS ON MOBILE
   ============================================ */

@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
        overflow-y: auto;
    }
    
    .modal-header {
        position: sticky;
        top: 0;
        background: var(--card-bg);
        z-index: 10;
        border-bottom: 1px solid var(--border-color);
    }
    
    .modal-close {
        width: 44px;
        height: 44px;
    }
}

/* ============================================
   ATTENDANCE PAGE MOBILE
   ============================================ */

@media (max-width: 768px) {
    /* Compact calendar */
    .days-container {
        gap: 0.25rem;
    }
    
    .day-button {
        min-width: 50px;
        padding: 0.375rem 0.5rem;
    }
    
    .day-weekday {
        font-size: 0.65rem;
    }
    
    .day-date {
        font-size: 1rem;
    }
    
    /* Attendance rows */
    .attendance-row {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .status-buttons {
        display: flex;
        gap: 0.5rem;
        width: 100%;
    }
    
    .status-btn {
        flex: 1;
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
        text-align: center;
    }
}

/* ============================================
   CHIPS/FILTERS ON MOBILE
   ============================================ */

@media (max-width: 768px) {
    .chips-container {
        display: flex;
        gap: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .chips-container::-webkit-scrollbar {
        height: 4px;
    }
    
    .chips-container::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 2px;
    }
    
    .chip {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* ============================================
   TYPOGRAPHY MOBILE
   ============================================ */

@media (max-width: 768px) {
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    .text-xl {
        font-size: 1.25rem;
    }
    
    .card-title {
        font-size: 1.25rem;
    }
}

/* ============================================
   SPACING MOBILE
   ============================================ */

@media (max-width: 768px) {
    .mb-2 {
        margin-bottom: 1rem;
    }
    
    .mt-2 {
        margin-top: 1rem;
    }
    
    .gap-1 {
        gap: 0.5rem;
    }
}

/* ============================================
   PAYMENTS PAGE MOBILE
   ============================================ */

@media (max-width: 768px) {
    /* Payment indicators */
    .overpaid-indicator,
    .underpaid-indicator {
        display: inline-block;
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
        border-radius: 4px;
        margin-left: 0.5rem;
    }
    
    .overpaid-indicator {
        background: #dcfce7;
        color: #16a34a;
    }
    
    .underpaid-indicator {
        background: #fef3c7;
        color: #d97706;
    }
    
    /* Paid row styling */
    .mobile-card.paid-row {
        background: rgba(34, 197, 94, 0.05);
        border-left: 3px solid #22c55e;
    }
}

/* ============================================
   SAFE AREA (iPhone notch)
   ============================================ */

@media (max-width: 768px) {
    .container {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .nav.mobile-open {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
