/* Mobile App Responsive Design - mobile.css */

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ===== MOBILE-FIRST CONTAINER ===== */
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 10px;
    position: relative;
}

/* Desktop */
@media (min-width: 1024px) {
    .container {
        max-width: 1200px;
        padding: 20px;
    }
}

/* ===== MOBILE HEADER ===== */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 0 0 20px 20px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 45px;
    height: 45px;
    background: linear-gradient(45deg, #4CAF50, #2196F3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.logo-text h1 {
    color: #2c3e50;
    font-size: 18px;
    margin-bottom: 2px;
    font-weight: 700;
}

.logo-text p {
    color: #7f8c8d;
    font-size: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.user-details h3 {
    color: #2c3e50;
    font-size: 14px;
    margin-bottom: 2px;
    font-weight: 600;
}

.user-details p {
    color: #7f8c8d;
    font-size: 11px;
}

/* Mobile Header - Stack vertically on very small screens */
@media (max-width: 480px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .logo-text h1 {
        font-size: 16px;
    }
}

/* ===== MOBILE NAVIGATION ===== */
.nav-menu {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 8px;
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-menu ul {
    list-style: none;
    display: flex;
    gap: 8px;
    padding: 0;
    min-width: max-content;
}

.nav-menu li {
    flex-shrink: 0;
}

.nav-menu a {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: #2c3e50;
    background: linear-gradient(45deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    text-align: center;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.3s ease;
    white-space: nowrap;
    border: 2px solid transparent;
    min-width: 90px;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: linear-gradient(45deg, #4CAF50, #2196F3);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

/* Vertical nav on mobile */
@media (max-width: 640px) {
    .nav-menu ul {
        flex-direction: column;
        gap: 6px;
    }
    
    .nav-menu li {
        width: 100%;
    }
    
    .nav-menu a {
        min-width: auto;
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* ===== MOBILE CARDS ===== */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f3f4;
    flex-wrap: wrap;
    gap: 10px;
}

.card-title {
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title::before {
    content: '';
    width: 3px;
    height: 20px;
    background: linear-gradient(45deg, #4CAF50, #2196F3);
    border-radius: 2px;
}

/* ===== MOBILE STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 18px 15px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
    transition: transform 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    transform: rotate(45deg);
}

.stat-card:active {
    transform: scale(0.98);
}

.stat-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.9;
}

.stat-number {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}

.stat-label {
    font-size: 11px;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

/* Single column on very small screens */
@media (max-width: 360px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== MOBILE BUTTONS ===== */
.btn {
    display: inline-block;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 100px;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transition: all 0.6s ease;
    transform: translate(-50%, -50%);
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(45deg, #4CAF50, #2196F3);
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.btn-success {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    color: white;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.btn-warning {
    background: linear-gradient(45deg, #f39c12, #e67e22);
    color: white;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3);
}

.btn-secondary {
    background: linear-gradient(45deg, #95a5a6, #7f8c8d);
    color: white;
    box-shadow: 0 4px 15px rgba(149, 165, 166, 0.3);
}

.btn-danger {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.btn:active {
    transform: translateY(1px);
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

/* Stack buttons vertically on mobile */
@media (max-width: 640px) {
    .btn-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 15px;
    }
}

/* ===== MOBILE FORMS ===== */
.form-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.form-col {
    flex: 1;
    min-width: 280px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #2c3e50;
    font-weight: 500;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: #fafbfc;
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: #4CAF50;
    background: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

/* Stack form columns on mobile */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-col {
        min-width: auto;
    }
}

/* ===== MOBILE TABLES ===== */
.table-responsive {
    overflow-x: auto;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 15px;
    overflow: hidden;
    min-width: 600px; /* Prevent table from being too narrow */
}

.table th {
    background: linear-gradient(45deg, #2c3e50, #34495e);
    color: white;
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table td {
    padding: 10px;
    border-bottom: 1px solid #f1f3f4;
    font-size: 13px;
    vertical-align: top;
}

.table tr:hover {
    background: #f8f9fa;
}

.table tr:last-child td {
    border-bottom: none;
}

/* Mobile table - Card layout for very small screens */
@media (max-width: 480px) {
    .table-responsive {
        overflow: visible;
    }
    
    .table {
        min-width: auto;
    }
    
    .table, .table tbody, .table tr, .table td {
        display: block;
        width: 100%;
    }
    
    .table thead {
        display: none;
    }
    
    .table tr {
        background: white;
        border-radius: 12px;
        margin-bottom: 10px;
        padding: 15px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .table td {
        border: none;
        padding: 5px 0;
        position: relative;
        padding-left: 35%;
    }
    
    .table td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 30%;
        font-weight: 600;
        color: #2c3e50;
        font-size: 12px;
    }
}

/* ===== MOBILE ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.alert-success {
    background: linear-gradient(45deg, #d4edda, #c3e6cb);
    color: #155724;
    border-left: 4px solid #28a745;
}

.alert-error {
    background: linear-gradient(45deg, #f8d7da, #f5c6cb);
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.alert-warning {
    background: linear-gradient(45deg, #fff3cd, #ffeaa7);
    color: #856404;
    border-left: 4px solid #ffc107;
}

.alert-info {
    background: linear-gradient(45deg, #d1ecf1, #bee5eb);
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

/* ===== MOBILE MODALS ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    margin: 10% auto;
    padding: 25px;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
    position: relative;
}

@keyframes modalSlideIn {
    from { 
        opacity: 0; 
        transform: translateY(-50px) scale(0.9); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f1f3f4;
}

.modal-header h3 {
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
}

.close {
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s ease;
    background: none;
    border: none;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

/* Mobile modal adjustments */
@media (max-width: 480px) {
    .modal-content {
        margin: 5% auto;
        width: 95%;
        padding: 20px;
        max-height: 90vh;
    }
}

/* ===== MOBILE UTILITIES ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.p-20 { padding: 20px; }
.hidden { display: none; }
.block { display: block; }
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-10 { gap: 10px; }

/* ===== MOBILE ANIMATIONS ===== */
.fade-in {
    animation: fadeIn 0.6s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-up {
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== MOBILE TOUCH IMPROVEMENTS ===== */
/* Larger touch targets */
.nav-menu a,
.btn,
.form-control,
.table button {
    min-height: 44px;
    min-width: 44px;
}

/* Prevent zoom on input focus (iOS) */
@media screen and (max-width: 767px) {
    .form-control {
        font-size: 16px;
    }
}

/* ===== MOBILE LOADING STATES ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #666;
    font-size: 14px;
}

.spinner {
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4CAF50;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

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

/* ===== MOBILE SAFE AREAS (iPhone X+) ===== */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }
    
    .header {
        padding-top: max(15px, env(safe-area-inset-top));
    }
}

/* ===== MOBILE DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .card,
    .modal-content {
        background: rgba(45, 55, 72, 0.95);
        color: #e2e8f0;
    }
    
    .form-control {
        background: rgba(74, 85, 104, 0.3);
        border-color: rgba(113, 128, 150, 0.3);
        color: #e2e8f0;
    }
    
    .table {
        background: rgba(45, 55, 72, 0.95);
        color: #e2e8f0;
    }
}

/* ===== MOBILE PERFORMANCE OPTIMIZATIONS ===== */
.stat-card,
.card,
.btn {
    will-change: transform;
}

.nav-menu {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.nav-menu::-webkit-scrollbar {
    display: none;
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
    .btn,
    .form-control,
    .card {
        border: 2px solid #000;
    }
}

/* ===== LANDSCAPE MOBILE OPTIMIZATIONS ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 10px 15px;
    }
    
    .logo-icon {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .stat-card {
        padding: 12px 10px;
    }
    
    .stat-icon {
        font-size: 24px;
        margin-bottom: 4px;
    }
    
    .stat-number {
        font-size: 16px;
    }
}