/* Parker Aviation - CFI Bootcamp @ KPAO
   Version: 1.2.0 */

:root {
    --primary: #1a56db;
    --primary-dark: #1444b0;
    --primary-light: #e8effc;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--gray-900);
    background: var(--gray-50);
    line-height: 1.5;
}

/* Nav */
.main-nav {
    display: flex;
    align-items: center;
    background: var(--gray-900);
    color: #fff;
    padding: 0 1.5rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand a {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
}
.nav-subtitle {
    color: var(--gray-300);
    font-size: 0.8rem;
    margin-left: 0.75rem;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 2rem;
    flex: 1;
}
.nav-links a {
    color: var(--gray-300);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}
.nav-links a:hover, .nav-links a.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
}
.nav-user { margin-left: auto; }
.nav-toggle { display: none; }

/* Content */
.content { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p { color: var(--gray-500); }

/* Stats */
.stats-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-width: 160px;
}
.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.85rem; color: var(--gray-500); }

/* Sections */
.section {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.section-header h2 { font-size: 1.15rem; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--gray-200);
}
.data-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
}
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table a { color: var(--primary); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.badge-intake { background: var(--gray-200); color: var(--gray-700); }
.badge-onboarding { background: #dbeafe; color: #1e40af; }
.badge-ground_training { background: #fef3c7; color: #92400e; }
.badge-flight_training { background: #d1fae5; color: #065f46; }
.badge-checkride_prep { background: #ede9fe; color: #5b21b6; }
.badge-checkride_scheduled { background: #fce7f3; color: #9d174d; }
.badge-checkride_complete, .badge-graduated { background: #d1fae5; color: var(--success); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: #fff;
    color: var(--gray-700);
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn:hover { background: var(--gray-100); }
.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.25rem;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--gray-500);
}
.empty-state .btn { margin-top: 0.75rem; }

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gray-900);
}
.login-container {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}
.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.login-header h1 { font-size: 1.5rem; color: var(--gray-900); }
.login-header p { color: var(--gray-500); font-size: 0.9rem; }
.login-form .btn { margin-top: 0.5rem; }

/* Page header layout */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.page-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 1rem;
}
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}
.filter-group { flex: 0 0 auto; }
.filter-input {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.85rem;
    min-width: 260px;
}
.filter-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.filter-select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.85rem;
    background: #fff;
}

/* Form rows */
.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0;
}
.form-row .form-group { flex: 1; }
.form-group-wide { flex: 2 !important; }
.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}
.subsection-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-top: 1rem;
    margin-bottom: 0.75rem;
}
.required { color: var(--danger); }
.form-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 0;
}

/* Checkbox labels */
.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400 !important;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}
.help-text {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.15rem;
}
.text-muted { color: var(--gray-500); font-size: 0.9rem; }

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 1.5rem;
}
.tab {
    padding: 0.65rem 1.25rem;
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--gray-700); }
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Communication entries */
.comm-form {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border: 1px solid var(--gray-200);
}
.comm-entry {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
}
.comm-entry:last-child { border-bottom: none; }
.comm-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}
.comm-direction { color: var(--gray-500); }
.comm-by { color: var(--gray-700); font-weight: 500; }
.comm-date { color: var(--gray-500); margin-left: auto; }
.comm-summary { font-size: 0.9rem; line-height: 1.5; }

/* Interview cards */
.interview-card {
    padding: 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}
.interview-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}
.interview-header .btn { margin-left: auto; }

/* Training stage pipeline */
.stage-pipeline {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 1rem 0;
    overflow-x: auto;
}
.stage-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
    font-size: 0.75rem;
    color: var(--gray-500);
    text-align: center;
}
.stage-step::before {
    content: '';
    position: absolute;
    top: 8px;
    left: -50%;
    right: 50%;
    height: 2px;
    background: var(--gray-200);
}
.stage-step:first-child::before { display: none; }
.stage-step.completed::before { background: var(--success); }
.stage-step.current::before { background: var(--success); }
.stage-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gray-200);
    border: 2px solid #fff;
    margin-bottom: 0.35rem;
    position: relative;
    z-index: 1;
}
.stage-step.completed .stage-dot { background: var(--success); }
.stage-step.current .stage-dot {
    background: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.stage-step.completed { color: var(--success); }
.stage-step.current { color: var(--primary); font-weight: 600; }

/* Q&A pairs */
.qa-pair {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
}
.qa-pair:last-child { border-bottom: none; }
.qa-question {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--gray-700);
    margin-bottom: 0.25rem;
}
.qa-answer {
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
}
.adhoc-pair {
    background: var(--gray-50);
    padding: 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    border: 1px solid var(--gray-200);
}

/* Progress bars */
.progress-bar {
    background: var(--gray-200);
    border-radius: 4px;
    height: 6px;
    display: inline-block;
    width: 80px;
    vertical-align: middle;
    margin-right: 0.25rem;
}
.progress-bar-lg {
    width: 100%;
    height: 10px;
    display: block;
}
.progress-fill {
    background: var(--success);
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

/* Checklist items */
.checklist-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item.completed { opacity: 0.6; }
.checklist-item.completed span { text-decoration: line-through; }
.checklist-check {
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: 400 !important;
}
.checklist-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Focus & debrief cards */
.focus-card, .debrief-card {
    padding: 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}
.focus-header, .debrief-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    flex-wrap: wrap;
}
.debrief-card p { font-size: 0.9rem; margin-top: 0.25rem; }

/* Danger button */
.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; }

/* Dashboard Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    align-items: start;
}
.dashboard-main { min-width: 0; }
.dashboard-sidebar { position: sticky; top: 72px; }

/* Calendar */
.calendar-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.calendar-month-label {
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 140px;
    text-align: center;
}
.calendar-legend {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}
.legend-session { background: #dbeafe; }
.legend-checkride { background: #ede9fe; }
.legend-student { background: #d1fae5; }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}
.calendar-header-cell {
    padding: 0.4rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}
.calendar-cell {
    min-height: 72px;
    padding: 0.2rem;
    border-right: 1px solid var(--gray-100);
    border-bottom: 1px solid var(--gray-100);
    background: #fff;
}
.calendar-cell:nth-child(7n) { border-right: none; }
.calendar-cell.other-month {
    background: var(--gray-50);
}
.calendar-cell.other-month .calendar-day-num { color: var(--gray-300); }
.calendar-cell.today {
    background: #fefce8;
}
.calendar-day-num {
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--gray-700);
    margin-bottom: 0.1rem;
    padding: 0 0.1rem;
}
.calendar-cell.today .calendar-day-num {
    color: var(--primary);
}
.calendar-event {
    font-size: 0.65rem;
    padding: 1px 3px;
    border-radius: 3px;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
    line-height: 1.4;
}
.event-session { background: #dbeafe; color: #1e40af; }
.event-checkride { background: #ede9fe; color: #5b21b6; font-weight: 600; }
.event-student { background: #d1fae5; color: #065f46; }
.event-more { background: var(--gray-100); color: var(--gray-500); font-style: italic; }

/* Checkride Board */
.checkride-card {
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-left: 3px solid var(--success);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}
.checkride-card.urgency-high { border-left-color: var(--danger); }
.checkride-card.urgency-med { border-left-color: var(--warning); }
.checkride-card.urgency-low { border-left-color: var(--success); }

.checkride-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.2rem;
}
.checkride-student {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary);
    text-decoration: none;
}
.checkride-student:hover { text-decoration: underline; }
.checkride-countdown {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
}
.countdown-green { background: #d1fae5; color: #065f46; }
.countdown-yellow { background: #fef3c7; color: #92400e; }
.countdown-red { background: #fef2f2; color: var(--danger); }

.checkride-info {
    font-size: 0.8rem;
    color: var(--gray-500);
    line-height: 1.5;
}
.checkride-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.35rem;
}
.checkride-progress .progress-bar { flex: 1; }
.checkride-progress .text-muted { font-size: 0.75rem; white-space: nowrap; }

/* Attention Items (sidebar) */
.attention-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100);
}
.attention-item:last-child { border-bottom: none; }
.attention-name {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--primary);
    text-decoration: none;
    display: block;
    margin-bottom: 0.2rem;
}
.attention-name:hover { text-decoration: underline; }
.attention-issues {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
}
.attention-issues .badge { font-size: 0.65rem; }

/* Mobile */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
        flex-direction: column;
        gap: 4px;
        background: none;
        border: none;
        cursor: pointer;
        margin-left: auto;
    }
    .nav-toggle span {
        display: block;
        width: 22px;
        height: 2px;
        background: #fff;
    }
    .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--gray-900);
        flex-direction: column;
        padding: 0.5rem;
        margin-left: 0;
    }
    .nav-links.open { display: flex; }
    .nav-links a { width: 100%; }
    .nav-user { margin-left: 0; margin-top: 0.5rem; border-top: 1px solid var(--gray-700); padding-top: 0.5rem; }
    .stats-row { flex-wrap: wrap; }
    .data-table { font-size: 0.8rem; }
    .form-row { flex-direction: column; gap: 0; }
    .filter-bar { flex-direction: column; }
    .filter-input { min-width: 100%; }
    .page-header-top { flex-direction: column; align-items: flex-start; }
    .tabs { overflow-x: auto; }
    .stage-pipeline { gap: 0.25rem; }
    .stage-step { font-size: 0.65rem; }
    .comm-meta { flex-wrap: wrap; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-sidebar { position: static; }
    .calendar-cell { min-height: 52px; }
    .calendar-event { font-size: 0.6rem; }
    .calendar-month-label { min-width: 120px; font-size: 0.85rem; }
}
