/* ===================================
   HELICOPTER LOGBOOK - MAIN STYLES
   Mobile-first, responsive design
   =================================== */

/* CSS Variables for theming */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --success-color: #16a34a;
    --warning-color: #f59e0b;
    --background: #ffffff;
    --surface: #f9fafb;
    --surface-hover: #f3f4f6;
    --border: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #111827;
        --surface: #1f2937;
        --surface-hover: #374151;
        --border: #374151;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --text-muted: #9ca3af;
    }
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
}

/* ===================================
   LAYOUT COMPONENTS
   =================================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.container-narrow {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Navigation */
.navbar {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

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

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.navbar-brand:hover {
    color: var(--primary-color);
}

.navbar-nav {
    display: flex;
    gap: 1rem;
    list-style: none;
    align-items: center;
}

.navbar-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.navbar-nav a:hover {
    color: var(--primary-color);
    background-color: var(--surface-hover);
}

.navbar-nav a.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* Mobile navigation */
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 768px) {
    .navbar-toggle {
        display: block;
    }

    .navbar-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--surface);
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
    }

    .navbar-nav.show {
        display: flex;
    }

    .navbar-nav a {
        width: 100%;
        padding: 0.75rem 1rem;
    }
}

/* ===================================
   CARDS & SURFACES
   =================================== */

.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card-header {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ===================================
   FORMS
   =================================== */

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-label.required::after {
    content: ' *';
    color: var(--danger-color);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background-color: var(--background);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.875rem;
    color: var(--danger-color);
    margin-top: 0.5rem;
}

/* Checkboxes and radios */
.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 1.125rem;
    height: 1.125rem;
    margin-right: 0.5rem;
    cursor: pointer;
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* ===================================
   BUTTONS
   =================================== */

.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

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

.btn-danger:hover:not(:disabled) {
    background-color: var(--danger-hover);
}

.btn-secondary {
    background-color: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--surface-hover);
}

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

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

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

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ===================================
   TABLES
   =================================== */

.table-container {
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

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

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background-color: var(--surface-hover);
}

.table tbody tr:hover {
    background-color: var(--surface-hover);
}

.table td {
    color: var(--text-primary);
}

.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
}

@media (max-width: 768px) {
    .table th,
    .table td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
}

/* ===================================
   ALERTS & MESSAGES
   =================================== */

.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid;
}

.alert-error {
    background-color: rgba(220, 38, 38, 0.1);
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.alert-success {
    background-color: rgba(22, 163, 74, 0.1);
    border-color: var(--success-color);
    color: var(--success-color);
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    border-color: var(--warning-color);
    color: var(--warning-color);
}

.alert-info {
    background-color: rgba(37, 99, 235, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ===================================
   PAGINATION
   =================================== */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem 0;
}

.pagination button,
.pagination span {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    background-color: var(--surface);
    color: var(--text-primary);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background-color: var(--surface-hover);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .page-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===================================
   UTILITY CLASSES
   =================================== */

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-secondary);
}

.text-small {
    font-size: 0.875rem;
}

.text-danger {
    color: var(--danger-color);
}

.text-success {
    color: var(--success-color);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.hidden {
    display: none !important;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Loading spinner */
.spinner {
    border: 3px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    animation: spin 0.8s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===================================
   LOGIN PAGE SPECIFIC
   =================================== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===================================
   DASHBOARD SPECIFIC
   =================================== */

.dashboard-header {
    margin-bottom: 2rem;
}

.dashboard-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.recent-flights-list {
    list-style: none;
}

.recent-flight-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.recent-flight-item:last-child {
    border-bottom: none;
}

.flight-info {
    flex: 1;
}

.flight-date {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.flight-details {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.flight-hours {
    font-weight: 700;
    color: var(--primary-color);
    white-space: nowrap;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media (max-width: 768px) {
    .container {
        padding: 0 0.75rem;
    }

    .card {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn-group .btn {
        width: 100%;
    }

    .table-actions {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    .table-actions .btn {
        width: 100%;
    }
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
    .navbar,
    .btn,
    .pagination,
    .form-group {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    .card {
        border: 1px solid black;
        page-break-inside: avoid;
    }
}
