/* Mobile-first responsive design for ARCSUSA */

/* Base mobile styles */
body {
    font-size: 14px;
    line-height: 1.5;
}

/* Touch-friendly button sizing */
.btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
}

.btn-sm {
    min-height: 36px;
    padding: 0.25rem 0.5rem;
}

/* Form enhancements for mobile */
.form-control,
.form-select {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
}

.form-check-input {
    width: 1.5em;
    height: 1.5em;
    margin-top: 0.125em;
}

/* Navigation improvements */
.navbar-toggler {
    padding: 0.5rem;
    border: none;
}

.navbar-collapse {
    background-color: var(--bs-dark);
    border-radius: 0.375rem;
    margin-top: 0.5rem;
    padding: 1rem;
}

/* Table responsiveness */
.table-responsive {
    border-radius: 0.375rem;
}

.table td,
.table th {
    padding: 0.75rem 0.5rem;
    vertical-align: middle;
}

/* Card enhancements */
.card {
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.card-header {
    padding: 0.75rem 1rem;
}

.card-body {
    padding: 1rem;
}

/* Modal improvements for mobile */
.modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
}

.modal-content {
    border-radius: 0.5rem;
}

/* Pagination mobile styles */
.pagination {
    justify-content: center;
    margin-bottom: 0;
}

.page-link {
    padding: 0.5rem 0.75rem;
    min-width: 44px;
    text-align: center;
}

/* Alert styles */
.alert {
    border-radius: 0.5rem;
    padding: 1rem;
}

.alert-dismissible .btn-close {
    padding: 1rem;
}

/* Badge improvements */
.badge {
    font-size: 0.75em;
    padding: 0.35em 0.65em;
}

/* Timeline styles for mobile */
.timeline {
    padding-left: 1.5rem;
}

.timeline::before {
    left: 0.75rem;
}

.timeline-marker {
    left: -2px;
}

/* File upload area */
.file-upload-area {
    border: 2px dashed var(--bs-border-color);
    border-radius: 0.5rem;
    padding: 2rem 1rem;
    text-align: center;
    transition: border-color 0.15s ease-in-out;
}

.file-upload-area:hover {
    border-color: var(--bs-primary);
}

.file-upload-area.dragover {
    border-color: var(--bs-primary);
    background-color: rgba(13, 110, 253, 0.05);
}

/* Accordion improvements */
.accordion-button {
    padding: 1rem;
}

.accordion-button:not(.collapsed) {
    background-color: var(--bs-primary-bg-subtle);
}

.accordion-body {
    padding: 1rem;
}

/* List group mobile styles */
.list-group-item {
    padding: 0.75rem 1rem;
}

.list-group-item-action {
    transition: background-color 0.15s ease-in-out;
}

/* Small screen optimizations */
@media (max-width: 576px) {
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .btn-group .btn {
        flex: 1;
    }
    
    /* Stack buttons vertically on small screens */
    .btn-toolbar .btn-group {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Adjust table for mobile */
    .table td,
    .table th {
        padding: 0.5rem 0.25rem;
    }
    
    /* Form adjustments */
    .row > .col-md-6,
    .row > .col-lg-6 {
        margin-bottom: 1rem;
    }
    
    /* Modal full screen on small devices */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }
    
    .modal-content {
        height: 100%;
        border-radius: 0;
    }
}

/* iPhone 6 Pro Max specific (414px) */
@media (max-width: 414px) {
    body {
        font-size: 13px;
    }
    
    .h1, .h2, .h3, .h4, .h5, .h6,
    h1, h2, h3, h4, h5, h6 {
        margin-bottom: 0.75rem;
    }
    
    .display-4 {
        font-size: 2.5rem;
    }
}

/* Samsung Galaxy and similar (up to 480px) */
@media (max-width: 480px) {
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .card-title {
        font-size: 1rem;
    }
    
    .table-responsive table {
        font-size: 0.875rem;
    }
    
    /* Compact spacing for forms */
    .mb-3 {
        margin-bottom: 1rem !important;
    }
    
    .mb-4 {
        margin-bottom: 1.25rem !important;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
    
    .py-5 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .btn:focus {
        transform: scale(1.02);
        transition: transform 0.1s ease-in-out;
    }
    
    .list-group-item-action:hover {
        background-color: var(--bs-gray-800);
    }
    
    .dropdown-item:hover {
        background-color: var(--bs-primary);
        color: var(--bs-white);
    }
}

/* High DPI display adjustments */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
    .card,
    .btn,
    .form-control,
    .form-select {
        border-width: 0.5px;
    }
}

/* Dark mode specific mobile adjustments */
@media (prefers-color-scheme: dark) {
    .file-upload-area {
        border-color: var(--bs-gray-600);
    }
    
    .timeline::before {
        background-color: var(--bs-gray-600);
    }
    
    .table-hover tbody tr:hover {
        background-color: rgba(255, 255, 255, 0.05);
    }
}

/* Loading states for mobile */
.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: currentColor;
    animation: spin 1s linear infinite;
}

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

/* Focus styles for accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--bs-primary);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}

/* Print styles */
@media print {
    .btn,
    .navbar,
    .pagination {
        display: none !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        break-inside: avoid;
    }
    
    .table {
        border-collapse: collapse !important;
    }
    
    .table td,
    .table th {
        border: 1px solid #000 !important;
    }
}
