/* =================================================================
   MOBILE-FIRST RESPONSIVE DESIGN FOR PENSION LOAN SYSTEM
   ================================================================= */

/* ===== MOBILE-FIRST BREAKPOINTS ===== */
:root {
    --mobile-xs: 320px;  /* Small phones */
    --mobile-sm: 375px;  /* Standard phones */
    --mobile-md: 425px;  /* Large phones */
    --tablet: 768px;     /* Tablets */
    --desktop: 1024px;   /* Small desktop */
    --desktop-lg: 1440px; /* Large desktop */
    
    /* Mobile-optimized spacing */
    --mobile-padding: 16px;
    --mobile-margin: 12px;
    --mobile-gap: 8px;
    
    /* Touch-friendly sizes */
    --touch-target: 44px;
    --touch-target-lg: 56px;
}

/* ===== BASE MOBILE STYLES (DEFAULT) ===== */

/* Mobile-first body adjustments */
body {
    font-size: 16px; /* Prevents zoom on iOS */
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
    overflow-x: hidden;
}

/* Mobile-first container */
.container {
    padding: var(--mobile-padding);
    margin: 0;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

/* ===== MOBILE HEADER IMPROVEMENTS ===== */
.top-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.header-container {
    padding: 12px var(--mobile-padding);
    flex-wrap: wrap;
    gap: 8px;
}

.header-logo-icon {
    font-size: 24px;
    padding: 6px;
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-name {
    font-size: 16px !important;
    line-height: 1.2;
}

.brand-tagline {
    font-size: 11px !important;
    opacity: 0.9;
}

/* ===== MOBILE NAVIGATION ===== */
.modern-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    z-index: 1001;
    background: var(--sidebar-bg);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    overflow-y: auto;
}

.modern-sidebar.mobile-open {
    transform: translateX(0);
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
    display: flex !important;
    flex-direction: column;
    justify-content: space-around;
    width: var(--touch-target);
    height: var(--touch-target);
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    cursor: pointer;
    padding: 8px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.mobile-menu-toggle span {
    display: block;
    height: 2px;
    width: 100%;
    background: white;
    border-radius: 1px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

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

/* Mobile sidebar links */
.sidebar-link {
    min-height: var(--touch-target-lg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    border-radius: 0;
    margin: 0 8px;
    transition: all 0.2s ease;
}

.sidebar-link:hover,
.sidebar-link:active {
    background: rgba(102, 126, 234, 0.1);
    transform: translateX(4px);
}

/* ===== MOBILE-FIRST FORMS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    font-size: 16px; /* Prevents zoom on iOS */
    background: var(--input-bg);
    transition: all 0.2s ease;
    box-sizing: border-box;
    min-height: var(--touch-target);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

/* Touch-friendly buttons */
button,
.btn {
    min-height: var(--touch-target);
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover,
.btn-primary:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

/* ===== MOBILE TABLE OPTIMIZATION ===== */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin: var(--mobile-margin) 0;
}

/* Hide table on mobile, show cards instead */
.records-table {
    display: none;
}

/* Mobile card layout for data */
.mobile-records-container {
    display: block;
    padding: 0;
}

.mobile-record-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
    position: relative;
    transition: all 0.2s ease;
}

.mobile-record-card:active {
    transform: translateY(1px);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.mobile-record-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.mobile-record-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.mobile-record-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 4px 0 0 0;
}

.mobile-record-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.mobile-record-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.mobile-record-detail {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mobile-record-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-record-value {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Mobile actions */
.mobile-record-actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.mobile-action-btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s ease;
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== MOBILE SEARCH & FILTERS ===== */
.search-container {
    position: sticky;
    top: 80px;
    z-index: 100;
    background: var(--bg-primary);
    padding: var(--mobile-padding);
    margin: 0 -16px 16px -16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.search-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-input {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--input-border);
    border-radius: 25px;
    font-size: 16px;
    background: var(--input-bg);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.search-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1), inset 0 2px 4px rgba(0,0,0,0.05);
}

.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
    -webkit-overflow-scrolling: touch;
}

.filter-chip {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}

.filter-chip.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* ===== MOBILE MODALS & DIALOGS ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    padding: 0;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    width: 100%;
    max-width: 100vw;
    max-height: 85vh;
    background: var(--bg-secondary);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 20px var(--mobile-padding) 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.modal-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
}

.modal-body {
    padding: 20px var(--mobile-padding);
    overflow-y: auto;
    max-height: 60vh;
}

/* ===== MOBILE NOTIFICATIONS ===== */
.notification {
    position: fixed;
    top: 90px;
    left: var(--mobile-padding);
    right: var(--mobile-padding);
    z-index: 3000;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transform: translateY(-100px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.notification.show {
    transform: translateY(0);
}

.notification-success {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.95), rgba(21, 128, 61, 0.95));
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.notification-error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(153, 27, 27, 0.95));
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.notification-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.95), rgba(180, 83, 9, 0.95));
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

/* ===== MOBILE LOADING STATES ===== */
.mobile-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px var(--mobile-padding);
    gap: 16px;
}

.mobile-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.mobile-loading-text {
    font-size: 16px;
    color: var(--text-secondary);
    text-align: center;
}

/* ===== MOBILE EMPTY STATES ===== */
.mobile-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px var(--mobile-padding) 40px;
    text-align: center;
    gap: 16px;
}

.mobile-empty-icon {
    font-size: 48px;
    opacity: 0.5;
}

.mobile-empty-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.mobile-empty-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Small phones (320px and up) */
@media (min-width: 320px) {
    .container {
        padding: 12px;
    }
    
    .mobile-record-details {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Standard phones (375px and up) */
@media (min-width: 375px) {
    .container {
        padding: 16px;
    }
    
    .mobile-record-details {
        grid-template-columns: 1fr 1fr;
    }
    
    .brand-name {
        font-size: 18px !important;
    }
}

/* Large phones (425px and up) */
@media (min-width: 425px) {
    .modal {
        align-items: center;
        padding: 20px;
    }
    
    .modal-content {
        width: 90%;
        max-height: 80vh;
        border-radius: 16px;
        transform: scale(0.9);
    }
    
    .modal.active .modal-content {
        transform: scale(1);
    }
    
    .mobile-record-actions {
        flex-direction: row;
    }
}

/* Tablets (768px and up) */
@media (min-width: 768px) {
    .modern-sidebar {
        position: relative;
        transform: translateX(0);
        width: 250px;
        height: auto;
        box-shadow: none;
    }
    
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
    
    .records-table {
        display: table;
    }
    
    .mobile-records-container {
        display: none;
    }
    
    .container {
        display: flex;
        padding: 20px;
        gap: 20px;
    }
    
    .main-content {
        flex: 1;
    }
    
    .search-container {
        position: relative;
        top: auto;
        margin: 0 0 20px 0;
        box-shadow: var(--shadow);
    }
    
    .search-box {
        flex-direction: row;
        align-items: center;
    }
    
    .notification {
        top: 20px;
        left: auto;
        right: 20px;
        width: 400px;
    }
}

/* Small desktop (1024px and up) */
@media (min-width: 1024px) {
    .modern-sidebar {
        width: 280px;
    }
    
    .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 30px;
    }
    
    .mobile-record-details {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Large desktop (1440px and up) */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
        padding: 40px;
    }
    
    .mobile-record-details {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .top-header,
    .modern-sidebar,
    .mobile-menu-toggle,
    .search-container,
    .mobile-record-actions,
    .sidebar-overlay {
        display: none !important;
    }
    
    .container {
        padding: 0;
        max-width: 100%;
    }
    
    .main-content {
        margin: 0;
        padding: 0;
    }
    
    .mobile-record-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode removed - system will always use light theme */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .form-control:focus,
    input:focus,
    select:focus,
    textarea:focus {
        border-width: 3px;
        box-shadow: 0 0 0 2px currentColor;
    }
    
    .btn-primary {
        background: #000;
        border: 2px solid #fff;
    }
}

/* ===== iOS SPECIFIC FIXES ===== */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    .form-control,
    input,
    select,
    textarea {
        border-radius: 0;
    }
    
    .notification {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(0,0,0,0.95);
    }
}

/* ===== ANDROID SPECIFIC FIXES ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-content {
        max-height: 70vh;
    }
    
    .mobile-empty-state {
        padding: 20px var(--mobile-padding);
    }
}