/* ========================================================================= */
/* CREW PLANNING DRIVER — mobile-first base styles                           */
/* ========================================================================= */

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #1f2937;
    background: #f9fafb;
    -webkit-font-smoothing: antialiased;
}

a { color: #f97316; text-decoration: none; }

:root {
    --primary: #f97316;
    --primary-dark: #ea580c;
    --primary-light: #fff7ed;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
}

/* ====== App Layout ====== */
.app {
    min-height: 100vh;
    padding-bottom: 80px;
}

.app-header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.app-header .back {
    background: var(--gray-100);
    border: none;
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    color: var(--gray-700);
    cursor: pointer;
}
.app-header h1 {
    flex: 1;
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    text-align: center;
    padding-right: 36px;
}
.app-header .header-action {
    background: var(--primary);
    color: white;
    border: none;
    width: 36px; height: 36px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

.container { padding: 16px; max-width: 760px; margin: 0 auto; }

/* ====== Bottom Nav ====== */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    z-index: 40;
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 10px 4px 8px;
    color: var(--gray-500);
    font-size: 11px;
    font-weight: 500;
    gap: 3px;
}
.bottom-nav a i { font-size: 18px; }
.bottom-nav a.active { color: var(--primary); }

/* ====== Cards ====== */
.card {
    background: white;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    border: 1px solid var(--gray-100);
}

/* ====== Buttons ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all .15s ease;
    text-decoration: none;
    font-family: inherit;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-block { width: 100%; }

/* ====== Forms ====== */
.input, .select, .textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    background: white;
    color: var(--gray-800);
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.1);
}
.label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
}
.field { margin-bottom: 14px; }

/* ====== Mission/Task items ====== */
.mission {
    background: white;
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 10px;
    border: 1px solid var(--gray-100);
    border-left: 4px solid var(--primary);
}
.mission-time {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.mission-time .time {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
}
.mission-type-badge {
    display: inline-block;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
}
.mission-type-arrival { background: #dbeafe; color: #1e40af; }
.mission-type-departure { background: #fef3c7; color: #92400e; }

.mission-info {
    font-size: 14px;
    color: var(--gray-700);
    line-height: 1.5;
}
.mission-info strong { color: var(--gray-800); }
.mission-info .row {
    display: flex; align-items: center; gap: 6px;
    margin-top: 4px;
    color: var(--gray-600);
}
.mission-info .row i { color: var(--gray-400); width: 14px; }

/* ====== Day grouping ====== */
.day-group { margin-bottom: 18px; }
.day-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0 0 8px;
    padding: 0 4px;
    text-transform: capitalize;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.day-title .count {
    font-size: 12px;
    background: var(--gray-100);
    color: var(--gray-600);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}

/* ====== Tasks ====== */
.task {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: white;
    padding: 14px;
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--gray-100);
}
.task .checkbox {
    width: 24px; height: 24px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    flex-shrink: 0;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    background: white;
    margin-top: 2px;
}
.task.done .checkbox {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.task.done .task-text { text-decoration: line-through; color: var(--gray-400); }
.task-body { flex: 1; min-width: 0; }
.task-text { font-size: 14px; color: var(--gray-800); line-height: 1.4; }
.task-meta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--gray-500);
    display: flex; gap: 8px; flex-wrap: wrap;
}
.task-meta .project-tag {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}

/* ====== Empty / loading ====== */
.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-400);
}
.empty i { font-size: 40px; margin-bottom: 12px; display: block; }

.spinner {
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    width: 28px; height: 28px;
    animation: spin .7s linear infinite;
    margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== Status badges ====== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }

/* ====== Toast ====== */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: white;
    padding: 12px 22px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: opacity .25s ease, transform .25s ease;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }

/* ====== Period switcher ====== */
.period-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: white;
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 14px;
    border: 1px solid var(--gray-200);
}
.period-switch button {
    border: none;
    background: transparent;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    border-radius: 8px;
    font-family: inherit;
}
.period-switch button.active {
    background: var(--primary);
    color: white;
}

/* ====== Date nav ====== */
.date-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    background: white;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
}
.date-nav button {
    background: var(--gray-100);
    border: none;
    width: 36px; height: 36px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    color: var(--gray-700);
}
.date-nav .label {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    text-transform: capitalize;
}
