/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.4;
    background-color: #f5f5f5;
    color: #333;
    display: flex;
    flex-direction: column;
}

/* Password Screen Styles */
.password-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #3d5a80;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.password-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.password-logo {
    max-width: 300px;
    height: auto;
}

.password-input {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border: none;
    border-radius: 4px;
    width: 250px;
    text-align: center;
}

.password-input:focus {
    outline: none;
    -webkit-box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.main-content {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    min-height: 100%;
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
}

.main-content.hidden {
    display: none;
}

/* Header */
header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    padding: 0.5rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
}

/* METAR Display */
.metar-display {
    position: absolute;
    left: 0.5rem;
    top: 50%;
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.75rem;
    max-width: 250px;
    z-index: 1;
}

/* Notes Display */
.notes-display {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    -webkit-transform: translateY(-50%);
    -ms-transform: translateY(-50%);
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.75rem;
    max-width: 250px;
    max-height: 100px;
    overflow-y: auto;
    z-index: 1;
    /* Add word wrapping to prevent overflow */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Hide METAR and Notes on smaller desktop screens to prevent overlap */
@media (max-width: 1024px) {
    .metar-display {
        max-width: 200px;
        font-size: 0.7rem;
        padding: 0.4rem 0.8rem;
    }
    
    .notes-display {
        max-width: 200px;
        font-size: 0.7rem;
        padding: 0.4rem 0.8rem;
        max-height: 80px;
    }
}

.metar-label {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.metar-text {
    font-family: 'Courier New', monospace;
    line-height: 1.3;
    word-wrap: break-word;
}

.metar-text.loading {
    opacity: 0.6;
    font-style: italic;
}

.metar-text.error {
    color: #ffcccc;
    font-style: italic;
}

.notes-label {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.notes-content {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.3;
    word-wrap: break-word;
    font-size: 0.7rem;
}

.notes-content.no-notes {
    opacity: 0.6;
    font-style: italic;
}

.note-preview-item {
    margin-bottom: 0.25rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.header-text {
    text-align: center;
    padding: 1rem 0;
}

.header-icon {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.header-icon-left {
    order: -1;
}

.header-icon-right {
    order: 1;
}

header h1 {
    font-size: 1.4rem;
    margin-bottom: 0.1rem;
}

header p {
    font-size: 0.85rem;
    opacity: 0.9;
}

.airport-name {
    font-size: 0.75rem;
    margin-top: 0.1rem;
    font-weight: 500;
}

/* Main Content */
main {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Controls Section */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.controls-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* Buttons */
.btn {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    -webkit-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

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

.btn-warning {
    background-color: #f39c12;
    color: white;
}

.btn-warning:hover {
    background-color: #d68910;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

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

.btn-complete {
    background-color: #17a2b8;
    color: white;
}

.btn-complete:hover {
    background-color: #138496;
}

.btn-invoice {
    background-color: #6f42c1;
    color: white;
}

.btn-invoice:hover {
    background-color: #5a32a3;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #117a8b;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Task List Section */
.task-list {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.task-list h2 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.25rem;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Table Container for Scrolling */
.table-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
}

/* Table Styles */
table {
    width: 100%;
    min-width: 1200px;
    border-collapse: collapse;
}

th, td {
    padding: 0.4rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 0.85rem;
}

/* Column width optimizations for new fields */
th:nth-child(1), td:nth-child(1) { /* Location */
    width: 8%;
}

th:nth-child(2), td:nth-child(2) { /* Date */
    width: 10%;
}

th:nth-child(3), td:nth-child(3) { /* Time */
    width: 6%;
}

th:nth-child(4), td:nth-child(4) { /* Aircraft N# */
    width: 8%;
}

th:nth-child(5), td:nth-child(5) { /* Country */
    width: 8%;
}

th:nth-child(6), td:nth-child(6) { /* Company */
    width: 10%;
}

th:nth-child(7), td:nth-child(7) { /* Description */
    width: 20%;
}

th:nth-child(8), td:nth-child(8) { /* Status */
    width: 10%;
}

th:nth-child(9), td:nth-child(9) { /* Accepted */
    width: 8%;
}

th:nth-child(10), td:nth-child(10) { /* Actions */
    width: 12%;
}

th {
    background-color: #2c3e50;
    color: white;
    font-weight: 500;
    position: sticky;
    top: 0;
    z-index: 10;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

tbody tr.accepted {
    background-color: #d4edda;
}

tbody tr.updated {
    background-color: #add8e6;
}

tbody tr.ready-invoice {
    background-color: #add8e6 !important; /* Light blue */
}

tbody tr.ready-invoice:hover {
    background-color: #b3e0f2 !important; /* Slightly lighter blue on hover */
}

tbody tr.invoiced {
    background-color: #ffcccc !important; /* Light red */
}

tbody tr.invoiced:hover {
    background-color: #ffb3b3 !important; /* Slightly darker light red on hover */
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-accepted {
    background-color: #d4edda;
    color: #155724;
}

.status-updated {
    background-color: #add8e6;
    color: #0c5460;
}

.status-ready-invoice {
    background-color: #add8e6; /* Light blue to match row background */
    color: #0c5460;
}

.status-invoiced {
    background-color: #ffcccc; /* Light red to match row background */
    color: #721c24;
}

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

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.modal-small {
    max-width: 350px;
}

.close {
    position: absolute;
    right: 1rem;
    top: 0.5rem;
    font-size: 2rem;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    -webkit-transition: color 0.3s;
    -o-transition: color 0.3s;
    transition: color 0.3s;
}

.close:hover {
    color: #333;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #2c3e50;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    -webkit-transition: border-color 0.3s;
    -o-transition: border-color 0.3s;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    -webkit-box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #666;
    font-style: italic;
}

/* 24-hour Time Picker */
.time-picker-24h {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 0.25rem;
}

.time-picker-24h select {
    width: auto;
    min-width: 70px;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    -webkit-transition: border-color 0.3s;
    -o-transition: border-color 0.3s;
    transition: border-color 0.3s;
    background-color: white;
}

.time-picker-24h select:focus {
    outline: none;
    border-color: #3498db;
    -webkit-box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.time-separator {
    font-size: 1.25rem;
    font-weight: bold;
    color: #2c3e50;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 2rem;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    -webkit-transform: translateY(100px);
    -ms-transform: translateY(100px);
    transform: translateY(100px);
    -webkit-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    -webkit-transform: translateY(0);
    -ms-transform: translateY(0);
    transform: translateY(0);
}

.toast.success {
    background-color: #27ae60;
}

.toast.error {
    background-color: #e74c3c;
}

.toast.info {
    background-color: #3498db;
}

/* Footer */
footer {
    text-align: center;
    padding: 0.5rem;
    background-color: #2c3e50;
    color: white;
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* Notes Management Modal Styles */
.notes-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.75rem;
    background-color: #f9f9f9;
}

.notes-list .no-notes {
    text-align: center;
    color: #999;
    font-style: italic;
    margin: 0;
}

.note-item {
    background: white;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    border-left: 3px solid #3498db;
    position: relative;
    padding-right: 2.5rem;
}

.note-item:last-child {
    margin-bottom: 0;
}

.note-text {
    margin: 0 0 0.25rem 0;
    color: #333;
    word-wrap: break-word;
}

.note-timestamp {
    font-size: 0.7rem;
    color: #666;
    margin: 0;
}

.note-delete {
    position: absolute;
    right: 0.5rem;
    top: 0.5rem;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    cursor: pointer;
    transition: background 0.2s;
}

.note-delete:hover {
    background: #c0392b;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .metar-display,
    .notes-display {
        position: static;
        transform: none;
        width: 100%;
        max-width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .header-icon {
        width: 35px;
        height: 35px;
    }
    
    .header-icon-left,
    .header-icon-right {
        order: 0;
    }
    
    header h1 {
        font-size: 1.1rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    table {
        font-size: 0.75rem;
    }
    
    th, td {
        padding: 0.3rem;
    }
    
    .modal-content {
        margin: 10% auto;
        padding: 1.5rem;
    }
}

/* Action Buttons in Table */
.action-buttons {
    display: flex;
    gap: 0.3rem;
    flex-wrap: nowrap;
}

/* No Tasks Message */
.no-tasks {
    text-align: center;
    padding: 2rem;
    color: #666;
    font-style: italic;
}

/* Loading Spinner */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    -webkit-animation: spin 1s linear infinite;
    animation: spin 1s linear infinite;
}

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

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

/* Checkbox Group Styles for Complete Modal */
.checkbox-group {
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f9f9f9;
}

.checkbox-row {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.checkbox-row input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
    cursor: pointer;
    transform: scale(1.2);
}

.checkbox-row input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.checkbox-row label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0;
    cursor: pointer;
}

.checkbox-row input[type="checkbox"]:disabled + label {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Additional inputs for Bags and Initials */
.additional-inputs {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.additional-inputs .input-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.additional-inputs .input-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0;
}

.additional-inputs .input-field input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 80px;
}

.additional-inputs .input-field input[type="number"] {
    width: 80px;
}

.additional-inputs .input-field input[type="text"] {
    width: 80px;
}

.additional-inputs .input-field input:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}

.datetime-inputs {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.datetime-inputs input[type="date"],
.datetime-inputs input[type="time"] {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.datetime-inputs input[type="date"]:disabled,
.datetime-inputs input[type="time"]:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Time Picker for Complete Modal */
.time-picker-24h-inline {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.time-picker-24h-inline select {
    flex: 1;
    min-width: 60px;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.3s;
    background-color: white;
}

.time-picker-24h-inline select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.time-picker-24h-inline select:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}

.time-picker-24h-inline .time-separator {
    font-size: 1rem;
    font-weight: bold;
    color: #2c3e50;
}

/* Real-time Sync Status Indicator */
.sync-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background-color: rgba(46, 204, 113, 0.1);
    border-radius: 4px;
    font-size: 0.85rem;
    color: #27ae60;
    margin-left: 15px;
}

.sync-indicator {
    width: 8px;
    height: 8px;
    background-color: #27ae60;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.9);
    }
}

.sync-text {
    font-weight: 500;
}

/* Archive Modal Styles */
.modal-large {
    max-width: 95%;
    width: 1400px;
}

.modal-subtitle {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin: -10px 0 15px 0;
    font-style: italic;
}

.archive-table-container {
    max-height: 600px;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#archiveTable {
    width: 100%;
    border-collapse: collapse;
}

#archiveTable thead {
    position: sticky;
    top: 0;
    background-color: #34495e;
    color: white;
    z-index: 10;
}

#archiveTable thead th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #2c3e50;
}

#archiveTable tbody tr {
    border-bottom: 1px solid #ecf0f1;
}

#archiveTable tbody tr:hover {
    background-color: #f8f9fa;
}

#archiveTable tbody td {
    padding: 12px;
    vertical-align: top;
}

/* Deleted row styling */
.deleted-row {
    background-color: #ffe6e6;
    opacity: 0.8;
}

.deleted-row:hover {
    background-color: #ffd9d9 !important;
}

.status-deleted {
    background-color: #e74c3c;
    color: white;
}

/* Archive controls styling */
.archive-controls {
    margin-bottom: 1rem;
    text-align: right;
}

/* Log entries display styling */
.log-entries-display {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.log-entries-display .no-logs {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

.log-entries-display .error-message {
    text-align: center;
    color: #e74c3c;
    padding: 20px;
}

.log-table-container {
    overflow-x: auto;
}

.log-preview-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.log-preview-table thead {
    background-color: #2c3e50;
    color: white;
    position: sticky;
    top: 0;
    z-index: 1;
}

.log-preview-table th,
.log-preview-table td {
    padding: 8px;
    text-align: left;
    border: 1px solid #ddd;
}

.log-preview-table tbody tr:nth-child(even) {
    background-color: #f2f2f2;
}

.log-preview-table tbody tr:hover {
    background-color: #e0e0e0;
}

.log-count {
    text-align: center;
    font-weight: bold;
    color: #2c3e50;
    margin-top: 10px;
}
