/* Flight Tracking System - Main Styles */
/* Responsive Design: Mobile-first approach with tablet and desktop optimization */
/* - Mobile (< 768px): Compact layout with smaller touch targets */
/* - Tablet (768-1023px): Touch-optimized for iPad portrait with larger buttons */
/* - Desktop (1024px+): Full-screen layout optimized for laptop/desktop use */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --success-color: #16a34a;
    --danger-color: #dc2626;
    --warning-color: #ea580c;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --border-color: #d1d5db;
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

.container {
    max-width: 100%; /* Full width on all screens */
    margin: 0 auto;
    padding: 20px;
}

/* Responsive container widths */
@media (min-width: 768px) {
    .container {
        max-width: 768px; /* iPad portrait width - optimized for tablets */
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 1200px; /* Desktop width - full screen on laptops/desktops */
    }
}

/* Header */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 24px;
}

.user-info {
    text-align: right;
    font-size: 14px;
}

/* Navigation */
nav {
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 0;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 20px;
}

nav a {
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    padding: 10px 15px;
    display: block;
    border-radius: 6px;
    transition: background-color 0.2s;
}

nav a:hover,
nav a.active {
    background-color: var(--bg-light);
    color: var(--primary-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 14px 24px;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 50px;
    touch-action: manipulation;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #15803d;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-lg {
    padding: 18px 32px;
    font-size: 20px;
    min-height: 60px;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 16px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 14px;
    font-size: 18px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: white;
    min-height: 50px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* Cards */
.card {
    background-color: var(--bg-white);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card-header {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-white);
}

th {
    background-color: var(--bg-light);
    padding: 14px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    font-size: 16px;
}

td {
    padding: 14px;
    border-bottom: 1px solid var(--border-color);
    font-size: 16px;
}

tr:hover {
    background-color: var(--bg-light);
}

/* Flight entry table - optimized for iPad */
.flight-entry-table {
    font-size: 16px;
}

.flight-entry-table input,
.flight-entry-table select {
    min-height: 44px;
    padding: 10px;
}

.flight-entry-table td {
    padding: 8px;
}

/* Timing controls */
.timing-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.timer-display {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
    min-width: 100px;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.badge-open {
    background-color: #dcfce7;
    color: #166534;
}

.badge-closed {
    background-color: #fed7aa;
    color: #9a3412;
}

.badge-locked {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Alerts */
.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-warning {
    background-color: #fed7aa;
    color: #92400e;
    border: 1px solid #fdba74;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* Loading spinner */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* Responsive adjustments */
/* Mobile devices (phones) */
@media (max-width: 767px) {
    .container {
        padding: 10px;
    }
    
    table {
        font-size: 14px;
    }
    
    th, td {
        padding: 10px 8px;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        min-height: 44px;
    }
    
    .btn-lg {
        padding: 14px 24px;
        font-size: 18px;
        min-height: 50px;
    }
}

/* Tablets (iPad portrait) - maintain touch-friendly sizes */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Keep existing touch-friendly button sizes for tablets */
    .btn {
        padding: 14px 24px;
        font-size: 18px;
        min-height: 50px;
    }
    
    .btn-lg {
        padding: 18px 32px;
        font-size: 20px;
        min-height: 60px;
    }
    
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"],
    input[type="number"],
    select,
    textarea {
        min-height: 50px;
        font-size: 18px;
    }
}

/* Laptops and desktops - optimize for full screen */
@media (min-width: 1024px) {
    .container {
        padding: 30px;
    }
    
    /* Adjust button sizes for desktop use */
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        min-height: 44px;
    }
    
    .btn-lg {
        padding: 14px 28px;
        font-size: 18px;
        min-height: 50px;
    }
    
    /* Optimize form inputs for desktop */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"],
    input[type="number"],
    select,
    textarea {
        min-height: 44px;
        font-size: 16px;
    }
    
    /* Optimize tables for larger screens */
    table {
        font-size: 15px;
    }
    
    th, td {
        padding: 12px 14px;
    }
    
    /* Better use of horizontal space */
    .flight-entry-table {
        font-size: 15px;
    }
    
    .flight-entry-table input,
    .flight-entry-table select {
        min-height: 40px;
        padding: 8px 12px;
    }
}

/* Print styles */
@media print {
    body {
        background-color: white;
    }
    
    .no-print {
        display: none !important;
    }
}

/* Utility classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.hidden { display: none; }
.float-right { float: right; }

/* Disabled field styling */
.field-disabled,
select.field-disabled,
input.field-disabled {
    background-color: #f3f4f6 !important;
    color: #9ca3af !important;
    cursor: not-allowed !important;
    opacity: 0.6;
}

select.field-disabled {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

/* Ensure disabled fields don't respond to pointer events on mobile */
select:disabled,
input:disabled,
textarea:disabled {
    pointer-events: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-white);
    margin: 20px;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.close-modal {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-light);
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
}

.close-modal:hover {
    color: var(--text-dark);
}

.modal-content form {
    padding: 20px;
}

/* Flight Actions Layout */
.flight-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.timing-controls {
    display: flex;
    gap: 8px;
}

/* Validation Error Styles */
.validation-error {
    border-color: #dc2626 !important;
    background-color: #fef2f2 !important;
}

.validation-error-message {
    color: #dc2626;
    font-size: 0.875em;
    margin-top: 5px;
}

.validation-success {
    border-color: #28a745 !important;
}

.required {
    color: #dc2626;
    font-weight: bold;
}

@media (max-width: 768px) {
    .modal-content {
        margin: 10px;
        max-height: 95vh;
    }
    
    .flight-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .timing-controls {
        width: 100%;
    }
    
    .timing-controls button {
        flex: 1;
    }
}

/* Admin Form Responsive Styles - One Field Per Line Layout */
/* Responsive strategy:
 * - Default/Tablet (768-1023px): 50px min-height for touch-friendly targets
 * - Mobile (<768px): 44px min-height (smaller screens need more compact layout)
 * - Desktop (1024px+): 44px min-height (mouse interaction doesn't need large targets)
 */
.admin-form-container {
    display: block;
    width: 100%;
}

.admin-form-group {
    display: block;
    margin-bottom: 15px;
    width: 100%;
}

.admin-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 16px;
}

.admin-form-group input[type="text"],
.admin-form-group input[type="number"],
.admin-form-group select,
.admin-form-group textarea {
    width: 100%;
    max-width: 500px;
    padding: 14px;
    font-size: 18px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: white;
    min-height: 50px;
}

.admin-form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.admin-form-group.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-form-group.checkbox input[type="checkbox"] {
    width: 24px;
    height: 24px;
    margin: 0;
    cursor: pointer;
}

.admin-form-group.checkbox label {
    margin-bottom: 0;
    cursor: pointer;
    font-weight: 600;
}

.admin-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Responsive adjustments for admin forms */
@media (max-width: 767px) {
    .admin-form-group input[type="text"],
    .admin-form-group input[type="number"],
    .admin-form-group select,
    .admin-form-group textarea {
        max-width: 100%;
        padding: 12px;
        font-size: 16px;
        min-height: 44px;
    }
    
    .admin-form-group textarea {
        min-height: 80px;
    }
    
    .admin-form-group.checkbox input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
    
    .admin-form-actions {
        flex-direction: column;
    }
    
    .admin-form-actions .btn {
        width: 100%;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    /* iPad/Tablet - maintain touch-friendly sizes */
    .admin-form-group input[type="text"],
    .admin-form-group input[type="number"],
    .admin-form-group select,
    .admin-form-group textarea {
        max-width: 600px;
    }
}

@media (min-width: 1024px) {
    /* Desktop - optimize for larger screens */
    .admin-form-group input[type="text"],
    .admin-form-group input[type="number"],
    .admin-form-group select,
    .admin-form-group textarea {
        max-width: 500px;
        min-height: 44px;
        font-size: 16px;
        padding: 12px;
    }
    
    .admin-form-group textarea {
        min-height: 100px;
    }
    
    .admin-form-group.checkbox input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
}

/* Responsive Form Layout - Multi-field per row with breakpoints */
/* Desktop (>1024px): Keep current multi-field layout
 * Tablet (768-1024px): 2 fields per row
 * Mobile (<768px): 1 field per row (stack vertically)
 */

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 16px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: white;
    min-height: 44px;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: auto;
    flex: 0 0 auto;
}

.form-group.checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
}

.form-group.checkbox label {
    margin-bottom: 0;
    cursor: pointer;
    font-weight: 600;
}

.form-group.full-width {
    flex: 0 0 100%;
}

/* Tablet - 2 fields per row */
@media (max-width: 1024px) and (min-width: 768px) {
    .form-group {
        /* 50% width minus half the gap (15px / 2 = 7.5px) for proper spacing */
        flex: 0 0 calc(50% - 7.5px);
        min-width: 250px;
    }
    
    .form-group.full-width {
        flex: 0 0 100%;
    }
    
    .form-group input[type="text"],
    .form-group input[type="number"],
    .form-group select,
    .form-group textarea {
        padding: 14px;
        min-height: 50px;
        font-size: 18px;
    }
}

/* Phone - 1 field per row */
@media (max-width: 767px) {
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        flex: 0 0 100%;
        min-width: auto;
    }
}

/* Form button actions */
.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

@media (max-width: 767px) {
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* Notification Styles */
#notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    border-radius: 4px;
    z-index: 9999;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: none;
}

.notification-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    animation: slideIn 0.3s ease-out;
}

.notification-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    animation: slideIn 0.3s ease-out;
}

/* Timezone label styling */
.timezone-label {
    font-size: 0.85em;
    color: #6b7280;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Button disabled state */
.btn-danger:disabled,
.btn-success:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-danger:disabled:hover,
.btn-success:disabled:hover {
    background-color: #6c757d;
}
