/* Turnpack Task Manager — Mobile-first CSS */

:root {
    --bg: #0f172a;
    --surface: #1a2332;
    --green-dark: #1B4332;
    --green: #2d6a4f;
    --green-hover: #40916c;
    --green-light: #1e3a2f;
    --blue: #3b82f6;
    --blue-light: #1e2a3a;
    --orange: #eab308;
    --orange-light: #2a2210;
    --red: #ef4444;
    --red-light: #2a1215;
    --gray: #94a3b8;
    --gray-light: #1a2332;
    --gray-border: #1e3a2f;
    --white: #f0fdf4;
    --text: #f0fdf4;
    --text-secondary: #94a3b8;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    padding-bottom: 70px; /* space for FAB */
}

/* ── Navbar ──────────────────────────────────────── */

.navbar {
    background: var(--bg);
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    height: 48px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.5px;
}

.nav-links { display: flex; gap: 2px; }

.nav-link {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.nav-link.active { color: var(--white); background: rgba(255,255,255,0.15); }
.nav-link:hover { color: var(--white); background: rgba(255,255,255,0.1); }
.nav-logout { color: rgba(255,255,255,0.5); }

/* ── Content ─────────────────────────────────────── */

.content { padding: 12px; max-width: 600px; margin: 0 auto; }

.page-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.page-header h1 { font-size: 20px; font-weight: 700; }

.back-link {
    color: var(--green);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

/* ── Toggle bar (My Tasks / Team) ───────────────── */

.toggle-bar {
    display: flex;
    gap: 0;
    background: var(--gray-border);
    border-radius: 6px;
    padding: 2px;
    margin-left: auto;
}

.toggle-btn {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.toggle-btn.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

/* ── Filter bar ─────────────────────────────────── */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.filter-select, .filter-search {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid var(--gray-border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    outline: none;
    appearance: auto;
}

.filter-search { min-width: 100%; }

.filter-select:focus, .filter-search:focus { border-color: var(--green); }

/* ── Tab bar (MO states) ────────────────────────── */

.tab-bar {
    display: flex;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    width: 100%;
    margin-bottom: 4px;
}

.tab {
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
}

.tab.active {
    color: var(--green-dark);
    border-bottom-color: var(--green-dark);
}

.list-meta { margin-bottom: 8px; }

/* ── Cards ───────────────────────────────────────── */

.card-group { margin-bottom: 16px; }

.group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    padding: 0 4px;
}

.group-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card {
    display: block;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
    margin-bottom: 6px;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.15s;
}

.card:active { box-shadow: 0 0 0 2px var(--green); }

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.task-name, .mo-name {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
    line-height: 1.3;
}

.card-bottom {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.mo-product { flex: 1; font-size: 13px; }
.mo-qty { font-weight: 600; }

.task-project {
    font-size: 11px;
    color: var(--gray);
    flex: 1;
}

.task-assignee {
    font-size: 11px;
    color: var(--gray);
}

/* ── Overdue / Today section colors ─────────────── */

.card-overdue {
    background: var(--red-light) !important;
    border-left: 3px solid var(--red);
}

.card-today {
    background: var(--orange-light) !important;
    border-left: 3px solid var(--orange);
}

.overdue-text { color: var(--red); font-weight: 600; }

.task-deadline {
    font-size: 11px;
    color: var(--gray);
    white-space: nowrap;
}

.section-overdue { border-left: 3px solid var(--red); padding-left: 8px; }
.section-today { border-left: 3px solid var(--orange); padding-left: 8px; }
.section-week { border-left: 3px solid var(--blue); padding-left: 8px; }

/* ── Collapsible groups ─────────────────────────── */

.collapsible { cursor: pointer; user-select: none; }

.collapse-icon {
    font-size: 10px;
    color: var(--gray);
    transition: transform 0.2s;
    display: inline-block;
}

.collapsible.collapsed .collapse-icon { transform: rotate(-90deg); }

.group-body { }
.collapsed + .group-body { display: none; }

/* ── Progress bar ────────────────────────────────── */

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--gray-border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--green);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-text { font-size: 11px; font-weight: 600; min-width: 28px; }

.progress-bar-lg { height: 10px; border-radius: 5px; margin-bottom: 4px; }

.progress-text-lg {
    font-size: 18px;
    font-weight: 700;
    color: var(--green-dark);
    display: block;
    text-align: center;
}

/* ── Badges ──────────────────────────────────────── */

.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.badge-stage { background: var(--blue-light); color: var(--blue); }
.badge-count { background: var(--gray-border); color: var(--text-secondary); }
.badge-gray { background: var(--gray-light); color: var(--gray); }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-green { background: var(--green-light); color: var(--green-dark); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-lg { font-size: 13px; padding: 4px 12px; }

/* ── Detail card ─────────────────────────────────── */

.detail-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
}

.detail-title { font-size: 18px; font-weight: 700; line-height: 1.3; }

.detail-meta { margin-bottom: 16px; }

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--gray-border);
}

.meta-label { font-size: 13px; color: var(--text-secondary); }
.meta-value { font-size: 13px; font-weight: 500; }
.meta-value a { color: var(--green); text-decoration: none; }

.detail-section { margin-top: 16px; }
.section-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.description-text { font-size: 13px; color: var(--text-secondary); line-height: 1.5; overflow-wrap: break-word; }
.completed-msg { font-size: 14px; color: var(--green); font-weight: 500; text-align: center; padding: 12px; }

/* ── Messages / Chatter ─────────────────────────── */

.message-item {
    border-bottom: 1px solid var(--gray-border);
    padding: 8px 0;
}

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

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.message-author { font-size: 12px; color: var(--text); }
.message-date { font-size: 11px; color: var(--gray); }
.message-body { font-size: 13px; color: var(--text-secondary); line-height: 1.4; overflow-wrap: break-word; }
.message-body p { margin-bottom: 4px; }

/* ── Forms ────────────────────────────────────────── */

.update-form { margin-top: 16px; }

.form-group { margin-bottom: 14px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.input-field {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    border: 1px solid var(--gray-border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.input-field:focus { border-color: var(--green); }

.textarea { resize: vertical; min-height: 60px; font-family: inherit; }

.range-input {
    width: 100%;
    height: 32px;
    accent-color: var(--green);
    cursor: pointer;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--gray);
    margin-top: -4px;
}

select.input-field {
    appearance: auto;
    cursor: pointer;
}

/* ── Buttons ─────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: opacity 0.15s;
    text-decoration: none;
}

.btn:active { opacity: 0.8; }
.btn-full { width: 100%; }
.btn-primary { background: var(--green); color: var(--white); }
.btn-primary:hover { background: var(--green-hover); }
.btn-success { background: var(--green-dark); color: var(--white); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.action-buttons { margin-top: 16px; }
.action-buttons form + form { margin-top: 8px; }

/* ── FAB (Floating Action Button) ───────────────── */

.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--green);
    color: #f0fdf4;
    font-size: 28px;
    font-weight: 300;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    cursor: pointer;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
    line-height: 1;
}

.fab:active { transform: scale(0.9); }
.fab:hover { background: var(--green-hover); }
.fab.open { background: var(--gray); transform: rotate(45deg); }

.fab-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 190;
}

.fab-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    padding: 20px 16px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    z-index: 195;
    max-height: 70vh;
    overflow-y: auto;
}

/* ── Alerts ──────────────────────────────────────── */

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 12px;
}

.alert-success { background: var(--green-light); color: var(--green-dark); }
.alert-error { background: var(--red-light); color: var(--red); }

/* ── Login ───────────────────────────────────────── */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding-bottom: 0;
}

.login-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 32px 24px;
    width: 90%;
    max-width: 320px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
    text-align: center;
}

.login-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--green-hover);
    margin-bottom: 2px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.login-card .input-field {
    text-align: center;
    letter-spacing: 8px;
    font-size: 24px;
    margin-bottom: 12px;
}

/* ── Status pills ───────────────────────────────── */

.pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pill {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--gray-border);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.pill:hover { border-color: var(--gray); }

.pill-blue.pill-active { background: var(--blue-light); color: var(--blue); border-color: var(--blue); }
.pill-orange.pill-active { background: var(--orange-light); color: var(--orange); border-color: var(--orange); }
.pill-green.pill-active { background: var(--green-light); color: var(--green-dark); border-color: var(--green); }
.pill-red.pill-active { background: var(--red-light); color: var(--red); border-color: var(--red); }

/* ── File upload ─────────────────────────────────── */

.file-upload { display: flex; align-items: center; gap: 8px; }
.file-input { display: none; }
.file-label { cursor: pointer; }

/* ── Empty state ─────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ── Utility ────────────────────────────────────── */

.hidden { display: none !important; }

/* ── HTMX loading indicator ──────────────────────── */

.htmx-request .btn { opacity: 0.6; pointer-events: none; }
.htmx-request .btn::after { content: "..."; }
