/* Mobile and Tablet Responsive Styles */

/* Base Mobile Styles */
@media screen and (max-width: 768px) {
    /* Reset and base styles */
    * {
        box-sizing: border-box;
    }
    
    body {
        margin: 0;
        padding: 0;
        font-size: 14px;
        line-height: 1.4;
    }
    
    .container {
        padding: 0 20px;
        max-width: 100%;
    }
    
    /* Header Mobile Styles */
    .app-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: white;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        padding: 12px 0;
    }
    
    .app-header .container {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .app-header .flex:first-child {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .app-header h1 {
        font-size: 16px;
        margin: 0;
    }
    
    .app-header img {
        height: 24px;
    }
    
    /* Hide all header controls except logo and title on mobile */
    .app-header .flex:last-child {
        display: none !important;
    }
    
    /* Hide the title on mobile to save space */
    .app-header h1 {
        display: none;
    }
    
    /* Mobile Navigation Toggle - create with CSS */
    .app-header .container::after {
        content: '\f0c9';
        font-family: 'Font Awesome 5 Free';
        font-weight: 900;
        font-size: 24px;
        color: #2563eb;
        cursor: pointer;
        padding: 8px;
        border-radius: 4px;
        transition: background-color 0.2s;
    }
    
    .app-header .container:hover::after {
        background-color: #f3f4f6;
    }
    
    .app-header .container.menu-open::after {
        content: '\f00d';
    }
    
    /* Mobile Burger Menu - slide down from header */
    .mobile-burger-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        z-index: 999;
        padding: 20px 16px;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .mobile-burger-menu.active {
        display: block;
        animation: slideDown 0.3s ease-out;
    }
    
    /* Navigation tabs inside burger menu */
    .mobile-burger-menu .nav-section {
        margin-bottom: 24px;
        padding-bottom: 16px;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .mobile-burger-menu .nav-section:last-child {
        border-bottom: none;
        margin-bottom: 0;
    }
    
    .mobile-burger-menu .nav-section h3 {
        font-size: 14px;
        font-weight: 600;
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin: 0 0 12px 0;
    }
    
    .mobile-burger-menu .nav-tab {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px;
        text-decoration: none;
        color: #374151;
        border-radius: 6px;
        transition: all 0.2s;
        margin-bottom: 4px;
    }
    
    .mobile-burger-menu .nav-tab:hover,
    .mobile-burger-menu .nav-tab.active {
        background-color: #eff6ff;
        color: #2563eb;
    }
    
    .mobile-burger-menu .nav-tab i {
        font-size: 18px;
        width: 20px;
        text-align: center;
    }
    
    .mobile-burger-menu .nav-tab span {
        font-weight: 500;
    }
    
    /* Header controls inside burger menu */
    .mobile-burger-menu .control-item {
        margin-bottom: 12px;
    }
    
    .mobile-burger-menu .control-item:last-child {
        margin-bottom: 0;
    }
    
    .mobile-burger-menu select,
    .mobile-burger-menu button {
        width: 100%;
        font-size: 14px;
        padding: 12px;
        border-radius: 6px;
        border: 1px solid #d1d5db;
    }
    
    .mobile-burger-menu .switch-container {
        display: flex;
        align-items: center;
        gap: 8px;
        justify-content: space-between;
        padding: 12px;
        background: #f9fafb;
        border-radius: 6px;
        border: 1px solid #e5e7eb;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    /* Navigation Tabs Mobile */
    .nav-tabs {
        display: none;
        flex-direction: column;
        gap: 0;
        margin-bottom: 16px;
        background: white;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .nav-tabs.active {
        display: flex;
    }
    
    .nav-tab {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 16px;
        text-decoration: none;
        color: #6b7280;
        border-bottom: 1px solid #e5e7eb;
        transition: all 0.2s;
    }
    
    .nav-tab:last-child {
        border-bottom: none;
    }
    
    .nav-tab:hover,
    .nav-tab.active {
        background-color: #eff6ff;
        color: #2563eb;
    }
    
    .nav-tab i {
        font-size: 18px;
        width: 20px;
    }
    
    .nav-tab span {
        font-weight: 500;
    }
    
    /* Mobile Menu Toggle Button */
    .mobile-menu-toggle {
        display: block;
        width: 100%;
        background: #2563eb;
        color: white;
        border: none;
        padding: 12px;
        border-radius: 8px;
        font-size: 16px;
        font-weight: 500;
        margin-bottom: 16px;
        cursor: pointer;
        transition: background-color 0.2s;
    }
    
    .mobile-menu-toggle:hover {
        background: #1d4ed8;
    }
    
    .mobile-menu-toggle i {
        margin-right: 8px;
    }
    
    /* Form Sections Mobile - More breathing room and better UX */
    .form-section {
        margin-top: 24px;
        padding: 0;
    }
    
    .form-section-header {
        margin-bottom: 24px;
        padding: 0 4px;
    }
    
    .form-section-title {
        font-size: 22px;
        margin: 0;
        color: #1f2937;
        font-weight: 600;
        line-height: 1.3;
    }
    
    /* Main content sections with better spacing */
    section[id$="-section"] {
        padding: 24px 0;
        min-height: 60vh;
    }
    
    /* Upload section specific improvements */
    #upload-section {
        padding: 32px 0;
    }
    
    #upload-section .form-section-title {
        font-size: 24px;
        margin-bottom: 8px;
        text-align: center;
    }
    
    /* Add subtle section dividers */
    section[id$="-section"]:not(:first-child) {
        border-top: 1px solid #f3f4f6;
        margin-top: 16px;
        padding-top: 32px;
    }
    
    /* Grid Layouts Mobile */
    .grid {
        display: block;
    }
    
    .grid > * {
        margin-bottom: 16px;
    }
    
    .grid-cols-2 > *,
    .grid-cols-4 > * {
        width: 100%;
    }
    
    /* Cards Mobile - Enhanced for better UX */
    .card {
        margin-bottom: 20px;
        padding: 20px;
        border-radius: 12px;
        background: white;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        border: 1px solid #f1f5f9;
        transition: all 0.2s ease;
    }
    
    .card:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.12);
        transform: translateY(-1px);
    }
    
    .card h3 {
        color: #1e293b;
        font-size: 18px;
        font-weight: 600;
        margin: 0 0 16px 0;
        padding-bottom: 8px;
        border-bottom: 2px solid #e2e8f0;
    }
    
    /* Form Controls Mobile - Human-centered design */
    .form-control {
        width: 100%;
        padding: 14px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        border: 2px solid #e2e8f0;
        border-radius: 8px;
        margin-bottom: 12px;
        background: #fafbfc;
        transition: all 0.2s ease;
        font-family: inherit;
    }
    
    .form-control:focus {
        outline: none;
        border-color: #2563eb;
        background: white;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        transform: translateY(-1px);
    }
    
    .form-control:hover {
        border-color: #cbd5e1;
        background: white;
    }
    
    .form-control::placeholder {
        color: #94a3b8;
        font-style: italic;
    }
    
    .form-group {
        margin-bottom: 20px;
    }
    
    .form-label {
        display: block;
        margin-bottom: 8px;
        font-weight: 600;
        color: #1e293b;
        font-size: 15px;
        line-height: 1.4;
    }
    
    /* Required field indicator */
    .form-label.required::after {
        content: " *";
        color: #ef4444;
        font-weight: bold;
    }
    
    /* Form validation states */
    .form-control.error {
        border-color: #ef4444;
        background: #fef2f2;
    }
    
    .form-control.success {
        border-color: #10b981;
        background: #f0fdf4;
    }
    
    .form-control.error:focus {
        box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
    }
    
    .form-control.success:focus {
        box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    }
    
    /* Buttons Mobile - Enhanced UX */
    .btn {
        width: 100%;
        padding: 16px 20px;
        font-size: 16px;
        border-radius: 10px;
        border: none;
        cursor: pointer;
        font-weight: 600;
        transition: all 0.3s ease;
        margin-bottom: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        position: relative;
        overflow: hidden;
        text-transform: none;
        letter-spacing: 0.5px;
        min-height: 52px;
    }
    
    .btn:active {
        transform: translateY(1px);
    }
    
    .btn-primary {
        background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
        color: white;
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    }
    
    .btn-primary:hover {
        background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
        box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
        transform: translateY(-2px);
    }
    
    .btn-secondary {
        background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
        color: white;
        box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
    }
    
    .btn-secondary:hover {
        background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
        box-shadow: 0 6px 16px rgba(107, 114, 128, 0.4);
        transform: translateY(-2px);
    }
    
    .btn i {
        font-size: 18px;
        transition: transform 0.2s ease;
    }
    
    .btn:hover i {
        transform: scale(1.1);
    }
    
    /* Upload Area Mobile - Enhanced UX */
    .upload-area {
        margin-bottom: 24px;
    }
    
    .dropzone {
        border: 3px dashed #cbd5e1;
        border-radius: 16px;
        padding: 32px 20px;
        text-align: center;
        background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
        transition: all 0.3s ease;
        position: relative;
        overflow: hidden;
    }
    
    .dropzone:hover {
        border-color: #2563eb;
        background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(37, 99, 235, 0.15);
    }
    
    .dropzone::before {
        content: '';
        position: absolute;
        top: -50%;
        left: -50%;
        width: 200%;
        height: 200%;
        background: radial-gradient(circle, rgba(37, 99, 235, 0.05) 0%, transparent 70%);
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
    }
    
    .dropzone:hover::before {
        opacity: 1;
    }
    
    .upload-button {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 12px;
        padding: 20px;
        background: white;
        border: 2px solid #e2e8f0;
        border-radius: 12px;
        cursor: pointer;
        transition: all 0.3s ease;
        width: 100%;
        margin-bottom: 16px;
        color: #374151;
        position: relative;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }
    
    .upload-button:hover {
        background: #f8fafc;
        border-color: #2563eb;
        color: #2563eb;
        transform: translateY(-3px);
        box-shadow: 0 8px 25px rgba(37, 99, 235, 0.15);
    }
    
    .upload-button:active {
        transform: translateY(-1px);
    }
    
    .upload-button i {
        font-size: 28px;
        color: #2563eb;
        transition: all 0.3s ease;
    }
    
    .upload-button:hover i {
        transform: scale(1.1) rotate(5deg);
    }
    
    .upload-button span {
        color: #1e293b;
        font-weight: 600;
        font-size: 16px;
        transition: color 0.3s ease;
    }
    
    .upload-button small {
        color: #64748b;
        font-size: 13px;
        font-weight: 500;
        transition: color 0.3s ease;
    }
    
    .upload-button:hover span,
    .upload-button:hover small {
        color: #2563eb;
    }
    
    /* Upload button ripple effect */
    .upload-button::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(37, 99, 235, 0.1);
        transform: translate(-50%, -50%);
        transition: width 0.3s ease, height 0.3s ease;
    }
    
    .upload-button:hover::after {
        width: 100%;
        height: 100%;
    }
    
    /* Table Mobile */
    .overflow-x-auto {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px; /* Extend to container edges */
        padding: 0 16px;
    }
    
    table {
        min-width: 100%;
        font-size: 14px;
        width: 100%;
    }
    
    th, td {
        padding: 6px 4px;
        font-size: 12px;
        min-width: 60px;
    }
    
    /* Make table inputs smaller on mobile */
    table .form-control {
        padding: 8px 6px;
        font-size: 14px;
        min-width: 50px;
        width: 100%;
    }
    
    /* Stack table rows vertically on very small screens */
    @media screen and (max-width: 480px) {
        .card table,
        .card thead,
        .card tbody,
        .card th,
        .card td,
        .card tr {
            display: block;
        }
        
        .card thead tr {
            position: absolute;
            top: -9999px;
            left: -9999px;
        }
        
        .card tr {
            border: 1px solid #e5e7eb;
            border-radius: 6px;
            margin-bottom: 12px;
            padding: 12px;
            background: #f9fafb;
        }
        
        .card td {
            border: none;
            position: relative;
            padding: 8px 0 8px 30%;
            text-align: left;
        }
        
        .card td:before {
            content: attr(data-label) ": ";
            position: absolute;
            left: 0;
            width: 25%;
            padding-right: 10px;
            white-space: nowrap;
            font-weight: 600;
            color: #374151;
        }
        
        .card td .form-control {
            width: 100%;
            margin: 0;
        }
    }
    
    /* PDF Viewer Mobile */
    .pdf-viewer {
        margin-top: 16px;
        height: 400px;
        border-radius: 8px;
        overflow: hidden;
    }
    
    .embed_pdf {
        width: 100%;
        height: 100%;
        border: none;
    }
    
    /* Modal Mobile */
    .modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 2000;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 16px;
    }
    
    .modal-content {
        background: white;
        border-radius: 8px;
        padding: 24px;
        width: 100%;
        max-width: 400px;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    /* Select2 Mobile Overrides */
    .select2-container {
        width: 100% !important;
    }
    
    .select2-container .select2-selection--single {
        height: 48px !important;
        line-height: 46px !important;
    }
    
    .select2-container .select2-selection__rendered {
        font-size: 16px !important;
        line-height: 46px !important;
    }
    
    /* Utility Classes Mobile */
    .hidden {
        display: none !important;
    }
    
    .text-center {
        text-align: center;
    }
    
    .text-left {
        text-align: left;
    }
    
    .flex {
        display: flex;
    }
    
    .items-center {
        align-items: center;
    }
    
    .justify-center {
        justify-content: center;
    }
    
    .justify-between {
        justify-content: space-between;
    }
    
    .gap-sm { gap: 4px; }
    .gap-md { gap: 8px; }
    .gap-lg { gap: 16px; }
    .gap-xl { gap: 24px; }
    
    .mb-xs { margin-bottom: 4px; }
    .mb-sm { margin-bottom: 8px; }
    .mb-md { margin-bottom: 16px; }
    .mb-lg { margin-bottom: 24px; }
    .mb-xl { margin-bottom: 32px; }
    
    .mt-sm { margin-top: 8px; }
    .mt-md { margin-top: 16px; }
    .mt-lg { margin-top: 24px; }
    .mt-xl { margin-top: 32px; }
    
    .p-sm { padding: 8px; }
    .p-md { padding: 16px; }
    .p-lg { padding: 24px; }
    
    /* Animation Classes */
    .animate-fade-in {
        animation: fadeIn 0.3s ease-in-out;
    }
    
    .animate-slide-up {
        animation: slideUp 0.3s ease-out;
    }
    
    .animate-bounce {
        animation: bounce 2s infinite;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    @keyframes slideUp {
        from { 
            opacity: 0;
            transform: translateY(20px);
        }
        to { 
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    @keyframes bounce {
        0%, 20%, 50%, 80%, 100% {
            transform: translateY(0);
        }
        40% {
            transform: translateY(-10px);
        }
        60% {
            transform: translateY(-5px);
        }
    }
}

/* Tablet Styles */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 0 24px;
    }
    
    .app-header h1 {
        font-size: 18px;
    }
    
    .app-header img {
        height: 28px;
    }
    
    /* Hide mobile navigation elements on tablet */
    .mobile-nav-toggle,
    .mobile-menu-toggle {
        display: none;
    }
    
    /* Show desktop navigation on tablet */
    .nav-tabs {
        display: flex !important;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .nav-tab {
        flex: 1;
        min-width: 120px;
        justify-content: center;
        padding: 12px 16px;
        border-radius: 6px;
        border: 1px solid #e5e7eb;
        background: white;
    }
    
    .nav-tab.active {
        background: #2563eb;
        color: white;
        border-color: #2563eb;
    }
    
    /* Header controls tablet */
    .header-controls {
        display: flex !important;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 16px;
        border-top: none;
        padding-top: 0;
    }
    
    .header-controls .flex {
        flex-direction: row;
        gap: 16px;
    }
    
    .header-controls select,
    .header-controls button {
        width: auto;
        min-width: 120px;
    }
    
    /* Grid layouts tablet */
    .grid-cols-2 {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
    
    .grid-cols-4 {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    /* Buttons tablet */
    .btn {
        width: auto;
        min-width: 120px;
        display: inline-flex;
    }
    
    /* Form sections tablet */
    .form-section {
        margin-top: 24px;
    }
    
    .form-section-title {
        font-size: 24px;
    }
    
    /* PDF viewer tablet */
    .pdf-viewer {
        height: 600px;
    }
    
    /* Table tablet */
    table {
        font-size: 15px;
    }
    
    th, td {
        padding: 12px;
    }
}

/* Large Tablet/Small Desktop */
@media screen and (min-width: 1025px) and (max-width: 1200px) {
    .container {
        max-width: 1024px;
        margin: 0 auto;
        padding: 0 32px;
    }
    
    .grid-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Hide desktop elements on mobile */
@media screen and (max-width: 768px) {
    .nav-tabs:not(.active) {
        display: none;
    }
    
    .header-controls:not(.active) {
        display: none;
    }
}

/* Show desktop elements on tablet and up */
@media screen and (min-width: 769px) {
    .mobile-nav-toggle,
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .nav-tabs,
    .header-controls {
        display: flex !important;
    }
}
