/* ========================================
   MOBILE RESPONSIVE STYLES
   Optimized for mobile devices
   ======================================== */

/* ========================================
   TABLET & SMALL DESKTOP (768px - 1024px)
   ======================================== */
@media (max-width: 1024px) and (min-width: 769px) {
    .container {
        padding: 0 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .page-header-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* ========================================
   TABLET PORTRAIT (481px - 768px)
   ======================================== */
@media (max-width: 768px) and (min-width: 481px) {
    /* Base Typography */
    body {
        font-size: 14px;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.2rem;
    }
    
    /* Container */
    .container {
        padding: 0 16px;
    }
    
    /* Header */
    .app-header {
        position: relative;
    }
    
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 0;
    }
    
    .header-brand {
        justify-content: center;
        margin-bottom: 8px;
    }
    
    .header-brand h1 {
        font-size: 1.4rem;
    }
    
    /* Navigation - Horizontal Scroll */
    .header-nav {
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 4px 0 8px 0;
        margin: 0 -16px;
        padding-left: 16px;
        padding-right: 16px;
    }
    
    .header-nav::-webkit-scrollbar {
        height: 3px;
    }
    
    .header-nav::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .header-nav::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }
    
    .nav-btn {
        font-size: 0.85rem;
        padding: 8px 16px;
        white-space: nowrap;
    }
    
    .header-actions {
        justify-content: center;
    }
    
    /* Main Content */
    .app-main {
        padding: 16px 0;
    }
    
    .page {
        padding: 0;
    }
    
    .page h2 {
        font-size: 1.4rem;
        margin-bottom: 16px;
    }
    
    /* Page Header */
    .page-header {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 16px;
    }
    
    .page-header-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .page-header-actions .btn {
        flex: 1;
        min-width: 140px;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-icon {
        font-size: 2rem;
    }
    
    .stat-info h3 {
        font-size: 1.3rem;
    }
    
    .stat-info p {
        font-size: 0.85rem;
    }
    
    /* Forms */
    .form-card {
        padding: 16px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .form-group label {
        font-size: 0.9rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    /* Tables */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }
    
    table {
        font-size: 0.85rem;
        min-width: 700px;
    }
    
    th, td {
        padding: 10px 8px;
    }
    
    /* Buttons */
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    /* Modals */
    .modal-content {
        width: 90%;
        max-width: 500px;
        margin: 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
}

/* ========================================
   MOBILE (320px - 480px)
   ======================================== */
@media (max-width: 480px) {
    /* Base Typography */
    body {
        font-size: 13px;
        line-height: 1.5;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    /* Container */
    .container {
        padding: 0 12px;
    }
    
    /* Login Screen */
    .login-card {
        padding: 30px 20px;
        max-width: 100%;
    }
    
    .login-card h1 {
        font-size: 2rem;
    }
    
    .login-card .subtitle {
        font-size: 0.9rem;
    }
    
    .login-demo-badge {
        position: static;
        margin: 0 auto 15px;
        display: inline-flex;
    }
    
    /* Header */
    .app-header {
        position: relative;
    }
    
    .header-content {
        flex-direction: column;
        gap: 10px;
        padding: 10px 0;
    }
    
    .header-brand {
        justify-content: center;
    }
    
    .header-brand-icon {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }
    
    .header-brand h1 {
        font-size: 1.2rem;
    }
    
    .header-brand .subtitle {
        font-size: 0.75rem;
    }
    
    /* Navigation - Full Width Buttons */
    .header-nav {
        width: 100%;
        flex-direction: column;
        gap: 6px;
        overflow-x: visible;
        padding: 0;
    }
    
    .nav-btn {
        width: 100%;
        justify-content: flex-start;
        padding: 10px 16px;
        font-size: 0.9rem;
        border-radius: 8px;
    }
    
    .nav-btn.active {
        background: rgba(255, 255, 255, 0.25);
    }
    
    .header-actions {
        width: 100%;
    }
    
    .header-actions .btn {
        width: 100%;
    }
    
    /* Demo Banner */
    .demo-banner {
        padding: 10px 0;
    }
    
    .demo-banner-content {
        font-size: 0.75rem;
        padding: 0 8px;
    }
    
    .demo-banner-icon {
        font-size: 1rem;
    }
    
    /* Main Content */
    .app-main {
        padding: 12px 0;
    }
    
    .page {
        padding: 0;
    }
    
    .page h2 {
        font-size: 1.2rem;
        margin-bottom: 12px;
    }
    
    /* Page Header */
    .page-header {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 12px;
    }
    
    .page-header h2 {
        font-size: 1.2rem;
    }
    
    .page-header-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .page-header-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Stats Grid - Stack Vertically */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .stat-card {
        padding: 14px;
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }
    
    .stat-icon {
        font-size: 2rem;
        margin-bottom: 0;
    }
    
    .stat-info {
        text-align: left;
    }
    
    .stat-info h3 {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }
    
    .stat-info p {
        font-size: 0.8rem;
    }
    
    /* Search Box */
    .search-box {
        margin-bottom: 12px;
    }
    
    .search-box input {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    /* Forms */
    .form-card {
        padding: 14px;
        margin-bottom: 12px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 10px;
    }
    
    .form-group {
        margin-bottom: 12px;
    }
    
    .form-group label {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px;
        padding: 10px 12px;
        width: 100%;
    }
    
    .form-group small {
        font-size: 0.75rem;
    }
    
    .form-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-top: 12px;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    /* Tables - Horizontal Scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -12px;
        padding: 0 12px;
        margin-bottom: 16px;
    }
    
    table {
        font-size: 0.75rem;
        min-width: 600px;
    }
    
    th, td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    
    th {
        font-size: 0.75rem;
        font-weight: 600;
    }
    
    /* Buttons */
    .btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
    
    .btn-small, .btn-sm {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    /* Filter Section */
    .filter-section {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .filter-section .form-row {
        gap: 10px;
    }
    
    /* Report Controls */
    .report-controls {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    /* Export Buttons */
    .export-buttons {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .export-buttons .btn {
        width: 100%;
    }
    
    /* Modals */
    .modal-content {
        width: 95%;
        max-width: 100%;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header {
        padding: 14px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 14px;
    }
    
    .modal-close {
        font-size: 1.5rem;
        padding: 4px 8px;
    }
    
    /* Settings Sections */
    .settings-section {
        margin-bottom: 20px;
    }
    
    .settings-section h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }
    
    /* Demo Limit Warning */
    .demo-limit-warning {
        padding: 10px 12px;
        margin: 12px 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .demo-limit-warning .warning-icon {
        font-size: 1.2rem;
    }
    
    .demo-limit-warning .warning-text {
        font-size: 0.85rem;
    }
    
    /* Toast Notifications */
    .toast {
        bottom: 20px;
        left: 12px;
        right: 12px;
        width: auto;
        font-size: 0.85rem;
        padding: 12px 16px;
    }
    
    /* Recent Section */
    .recent-section {
        margin-top: 20px;
    }
    
    .recent-section h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }
}

/* ========================================
   EXTRA SMALL MOBILE (max-width: 360px)
   ======================================== */
@media (max-width: 360px) {
    body {
        font-size: 12px;
    }
    
    .container {
        padding: 0 10px;
    }
    
    .login-card {
        padding: 25px 15px;
    }
    
    .login-card h1 {
        font-size: 1.8rem;
    }
    
    .header-brand h1 {
        font-size: 1.1rem;
    }
    
    .page h2 {
        font-size: 1.1rem;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-icon {
        font-size: 1.8rem;
    }
    
    .stat-info h3 {
        font-size: 1.1rem;
    }
    
    .form-card {
        padding: 12px;
    }
    
    table {
        font-size: 0.7rem;
    }
    
    th, td {
        padding: 6px 4px;
    }
    
    .btn {
        padding: 8px 14px;
        font-size: 0.8rem;
    }
}

/* ========================================
   LANDSCAPE ORIENTATION
   ======================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .app-header {
        position: relative;
    }
    
    .header-content {
        padding: 8px 0;
    }
    
    .header-brand-icon {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }
    
    .header-brand h1 {
        font-size: 1.1rem;
    }
    
    .header-brand .subtitle {
        display: none;
    }
    
    .nav-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .app-main {
        padding: 10px 0;
    }
    
    .page h2 {
        margin-bottom: 10px;
        font-size: 1.2rem;
    }
    
    .stat-card {
        padding: 10px;
    }
    
    .form-card {
        padding: 12px;
    }
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn {
        min-height: 44px;
        padding: 12px 20px;
    }
    
    .nav-btn {
        min-height: 44px;
    }
    
    input,
    select,
    textarea {
        min-height: 44px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Better scrolling */
    .table-container,
    .header-nav {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    /* Remove hover effects on touch */
    .btn:hover,
    .nav-btn:hover {
        transform: none;
    }
    
    /* Active states for touch */
    .btn:active {
        transform: scale(0.98);
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .app-header,
    .header-nav,
    .header-actions,
    .demo-banner,
    .demo-watermark,
    .page-header-actions,
    .form-actions,
    .btn,
    .modal,
    .toast {
        display: none !important;
    }
    
    .app-main {
        padding: 0;
    }
    
    .page {
        padding: 0;
    }
    
    table {
        page-break-inside: avoid;
    }
    
    .stat-card {
        page-break-inside: avoid;
    }
}
