/* ============================================================
   AGET — Maritime extraction dashboard
   Light mode by default, optional dark mode via [data-theme=dark]
   ============================================================ */

/* ---------- Theme tokens ---------- */
:root {
    --bg:             #f4f5f7;
    --surface:        #ffffff;
    --surface-alt:    #fafbfc;
    --border:         #e3e6ea;
    --border-strong:  #cdd2d8;

    --text:           #1f2328;
    --text-muted:     #57606a;
    --text-dim:       #8b939c;

    --brand:          #1e4d8b;          /* deep navy — maritime */
    --brand-hover:    #17406f;
    --brand-soft:     #e8eef7;

    --accent:         #0e7c66;          /* muted teal for secondary */
    --green:          #2f8c4e;
    --green-soft:     #e5f3e9;
    --red:            #c03939;
    --red-soft:       #fbe8e8;
    --amber:          #a96b16;
    --amber-soft:     #faf0dc;
    --blue-soft:      #e5eff8;

    --shadow-sm:      0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow:         0 2px 6px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-lg:      0 8px 24px rgba(15, 23, 42, 0.08);

    --radius:         8px;
    --radius-lg:      12px;

    --font-sans:      "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono:      "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="dark"] {
    --bg:             #0f1419;
    --surface:        #171c23;
    --surface-alt:    #1d232b;
    --border:         #2a313b;
    --border-strong:  #3a424d;

    --text:           #e6e8ea;
    --text-muted:     #9aa3ad;
    --text-dim:       #6b7480;

    --brand:          #4d8cdb;
    --brand-hover:    #6aa0e6;
    --brand-soft:     #1c2a3e;

    --accent:         #3fa68e;
    --green:          #4bb069;
    --green-soft:     #16301f;
    --red:            #e06565;
    --red-soft:       #341818;
    --amber:          #d49c4a;
    --amber-soft:     #2f2413;
    --blue-soft:      #16263a;

    --shadow-sm:      0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow:         0 2px 6px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-lg:      0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--text); }
h1 { font-size: 22px; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; font-weight: 600; }
p  { margin: 0; color: var(--text-muted); }
a  { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }

/* ---------- Navigation ---------- */
.navbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 24px;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    color: var(--text); font-weight: 700; font-size: 16px;
    letter-spacing: -0.01em;
}
.brand:hover { color: var(--text); }
.brand .brand-text {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.08em;
    color: var(--text);
}
.brand .sub {
    margin-left: 4px; color: var(--text-muted);
    font-weight: 600; font-size: 11px;
    letter-spacing: 0.12em;
    padding: 2px 7px;
    background: var(--brand-soft);
    color: var(--brand);
    border-radius: 4px;
}
.brand .logo-mark {
    width: 30px; height: 30px; border-radius: 7px;
    background: var(--brand);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}

.navbar .spacer { flex: 1; }

.nav-link {
    padding: 6px 12px; border-radius: 6px;
    color: var(--text-muted); font-weight: 500; font-size: 13px;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-alt); color: var(--text); }
.nav-link.active { color: var(--brand); background: var(--brand-soft); }

.theme-toggle {
    width: 34px; height: 34px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    transition: background .15s, color .15s, border-color .15s;
}
.theme-toggle:hover { background: var(--surface-alt); color: var(--text); border-color: var(--border-strong); }
.theme-toggle .sun  { display: block; }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun  { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }

.user-badge {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 10px 4px 4px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13px; color: var(--text);
}
.user-badge .avatar {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600;
}

.btn-logout {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 6px;
    color: var(--text-muted); font-size: 13px; font-weight: 500;
}
.btn-logout:hover { background: var(--red-soft); color: var(--red); }

/* ---------- Layout ---------- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* ---------- Page header ---------- */
.page-header {
    margin-bottom: 20px;
}
.page-header h1 { margin-bottom: 4px; }
.page-header p  { font-size: 13px; color: var(--text-muted); }

/* ---------- Marine hero (with animated waves) ---------- */
.hero {
    position: relative;
    display: flex; align-items: center; justify-content: space-between;
    gap: 20px;
    padding: 22px 26px;
    margin-bottom: 24px;
    background: linear-gradient(135deg,
                var(--brand-soft) 0%,
                var(--surface) 55%,
                var(--surface) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.hero-content { flex: 1 1 auto; min-width: 0; }
.hero-content h1 {
    font-size: 24px; font-weight: 700; margin-bottom: 6px;
    letter-spacing: -0.01em;
}
.hero-content p {
    font-size: 13px; color: var(--text-muted); margin-bottom: 10px;
}
.hero-ship {
    flex: 0 0 auto;
    color: var(--brand);
    filter: drop-shadow(0 4px 10px rgba(30, 77, 139, 0.15));
    animation: hero-breathe 6s ease-in-out infinite;
}
@keyframes hero-breathe {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-2px); }
}
.hero-ship .ship-float {
    transform-origin: center;
    animation: ship-bob 4s ease-in-out infinite;
}
@keyframes ship-bob {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25%      { transform: translate(0, -1px) rotate(-0.6deg); }
    75%      { transform: translate(0, 1px) rotate(0.6deg); }
}
.hero-ship .wave {
    animation-name: wave-slide;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}
.hero-ship .wave-back  { animation-duration: 9s; }
.hero-ship .wave-mid   { animation-duration: 6s; animation-direction: reverse; }
.hero-ship .wave-front { animation-duration: 4s; }
@keyframes wave-slide {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-60px); }
}
@media (max-width: 720px) {
    .hero { flex-direction: column; text-align: center; padding: 20px; }
    .hero-ship { margin-top: 6px; }
}

.inbox-badge {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 8px;
    padding: 4px 10px;
    background: var(--blue-soft); color: var(--brand);
    border-radius: 14px;
    font-size: 12px; font-weight: 500;
    font-family: var(--font-mono);
}
.inbox-badge::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(47, 140, 78, 0.18);
}

/* ---------- Stats ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    position: relative;
    transition: border-color .15s, box-shadow .15s;
}
.stat-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.stat-card .label {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-muted);
}
.stat-card .value {
    font-size: 28px; font-weight: 700;
    color: var(--text);
    margin-top: 4px;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.stat-card .sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.stat-card .stat-icon {
    position: absolute; top: 12px; right: 12px;
    color: var(--text-dim); opacity: 0.45;
}
.stat-card.brand  .value { color: var(--brand); }
.stat-card.green  .value { color: var(--green); }
.stat-card.red    .value { color: var(--red); }
.stat-card.amber  .value { color: var(--amber); }

/* ---------- Section header ---------- */
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin: 20px 0 12px 0;
}
.section-header h2 {
    display: flex; align-items: center; gap: 8px;
    color: var(--text); font-size: 16px; font-weight: 600;
}
.section-header h2 svg { color: var(--text-muted); }
.section-sub {
    font-size: 12px; color: var(--text-muted);
}
.section-sub code {
    font-family: var(--font-mono);
    color: var(--brand);
    background: var(--brand-soft);
    padding: 1px 6px; border-radius: 4px;
    font-size: 12px;
}

/* ---------- Card ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* ---------- Upload area ---------- */
.upload-area {
    background: var(--surface);
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--brand);
    background: var(--brand-soft);
}
.upload-area .up-icon {
    width: 52px; height: 52px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    display: flex; align-items: center; justify-content: center;
}
.upload-area h3 { font-size: 15px; margin-bottom: 4px; }
.upload-area p  { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.upload-area input[type="file"] { display: none; }

.formats { display: flex; gap: 6px; justify-content: center; }
.format-chip {
    padding: 2px 10px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 11px; font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

/* ---------- Ship picker ---------- */
.ship-picker {
    display: flex; align-items: center; gap: 10px;
    margin-top: 12px; padding: 10px 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
}
.ship-picker label {
    color: var(--text-muted); font-weight: 500;
    white-space: nowrap;
}
.ship-picker select {
    flex: 1;
    padding: 6px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit; font-size: 13px;
    cursor: pointer;
}
.ship-picker select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.ship-picker .hint { color: var(--text-dim); font-size: 12px; }

/* ---------- File list ---------- */
.file-list {
    margin-top: 12px;
    display: flex; flex-direction: column; gap: 6px;
}
.file-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}
.file-item .ext {
    padding: 2px 6px;
    background: var(--surface-alt);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 10px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}
.file-item .name { flex: 1; color: var(--text); }
.file-item .size { color: var(--text-dim); font-size: 12px; }
.file-item .rm {
    width: 22px; height: 22px; border-radius: 4px;
    border: none; background: transparent;
    color: var(--text-dim); cursor: pointer;
}
.file-item .rm:hover { background: var(--red-soft); color: var(--red); }

/* ---------- Buttons ---------- */
.btn-row { display: flex; gap: 8px; margin-top: 12px; }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-family: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    border: 1px solid transparent;
}
.btn-primary {
    background: var(--brand);
    color: #fff;
}
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:disabled { background: var(--border-strong); cursor: not-allowed; }

.btn-secondary {
    background: var(--surface);
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-alt); color: var(--text); border-color: var(--border-strong); }

/* ---------- Processing banner ---------- */
.processing-banner {
    display: none;
    align-items: center; gap: 12px;
    padding: 14px 16px; margin-top: 12px;
    background: var(--blue-soft);
    border: 1px solid var(--brand);
    border-left-width: 4px;
    border-radius: var(--radius);
}
.processing-banner.show { display: flex; }
.processing-banner .text h4 {
    color: var(--brand); margin-bottom: 2px;
}
.processing-banner .text p {
    color: var(--text-muted); font-size: 12px;
}

.spinner {
    width: 22px; height: 22px;
    border: 2.5px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Result banner ---------- */
.result-banner {
    display: none;
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    border: 1px solid;
}
.result-banner.show { display: block; }
.result-banner.ok {
    background: var(--green-soft);
    border-color: var(--green);
    color: var(--green);
}
.result-banner.err {
    background: var(--red-soft);
    border-color: var(--red);
    color: var(--red);
}
.result-banner h4 {
    font-size: 13px; margin-bottom: 2px; font-weight: 600;
    color: inherit;
}
.result-banner p { color: inherit; font-size: 12px; }
.result-banner .dl {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 8px;
    padding: 6px 12px;
    background: var(--surface);
    color: var(--text); border: 1px solid var(--border);
    border-radius: 5px;
    font-weight: 600; font-size: 12px;
}
.result-banner .dl:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- Voyages preview ---------- */
.voyages-preview {
    margin-top: 10px;
    max-height: 280px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.voyages-preview table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.voyages-preview th {
    background: var(--surface-alt);
    padding: 6px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em;
}
.voyages-preview td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.voyages-preview tr:last-child td { border-bottom: none; }

/* ---------- Jobs table ---------- */
.jobs-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.jobs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.jobs-table th {
    background: var(--surface-alt);
    padding: 10px 14px;
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}
.jobs-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}
.jobs-table tbody tr:last-child td { border-bottom: none; }
.jobs-table tbody tr:hover { background: var(--surface-alt); }

.id-mono {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    padding: 1px 6px;
    background: var(--surface-alt);
    border-radius: 4px;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px; font-weight: 600;
    text-transform: capitalize;
}
.badge.done,
.badge.email   { background: var(--green-soft); color: var(--green); }
.badge.error   { background: var(--red-soft);   color: var(--red); }
.badge.processing,
.badge.queued  { background: var(--amber-soft); color: var(--amber); }
.badge.manual  { background: var(--blue-soft);  color: var(--brand); }

.dl-link {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px;
    background: var(--brand-soft);
    color: var(--brand);
    border-radius: 5px;
    font-size: 12px; font-weight: 600;
    transition: background .15s;
}
.dl-link:hover { background: var(--brand); color: #fff; }

/* ---------- Empty state ---------- */
.empty-row td {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}
.empty-row .empty-ico {
    color: var(--text-dim); opacity: 0.5;
    margin-bottom: 6px;
}
.empty-row .empty-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ---------- Filters (jobs page) ---------- */
.filters {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 14px;
}
.filter-chip {
    padding: 5px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 12px; font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
}
.filter-chip:hover { border-color: var(--border-strong); color: var(--text); }
.filter-chip.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.reprocess-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 12px; font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
}
.reprocess-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background: var(--bg);
}

.login-card {
    width: 100%; max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 32px 28px;
}
.login-card .logo-mark {
    width: 72px; height: 52px; border-radius: 10px;
    background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
    padding: 6px 10px;
}
.login-card h1 {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
    color: var(--brand);
}
.login-card .subtitle {
    text-align: center;
    color: var(--text-muted); font-size: 13px;
    margin-bottom: 24px;
}
.login-card .form-group { margin-bottom: 14px; }
.login-card label {
    display: block;
    font-size: 12px; font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.login-card input {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit; font-size: 14px;
}
.login-card input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.login-card .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
    font-size: 14px;
    margin-top: 4px;
}
.login-card .err {
    padding: 8px 12px;
    background: var(--red-soft);
    color: var(--red);
    border: 1px solid var(--red);
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 12px;
}
.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 11px;
    color: var(--text-dim);
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
    .navbar { padding: 0 12px; gap: 4px; }
    .nav-link { padding: 6px 8px; }
    .user-badge { display: none; }
    .container { padding: 16px; }
    .jobs-table th:nth-child(7),
    .jobs-table td:nth-child(7) { display: none; }
}

/* ---------- Icon buttons (delete, etc.) ---------- */
.row-actions {
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}
.icon-btn:hover {
    background: var(--surface-alt);
    color: var(--text);
    border-color: var(--border-strong);
}
.icon-btn.danger:hover {
    background: var(--red-soft);
    color: var(--red);
    border-color: var(--red);
}
.icon-btn:active { transform: scale(0.94); }

/* Row deletion animation */
.jobs-table tr.deleting {
    animation: row-fade 0.35s ease forwards;
}
@keyframes row-fade {
    to { opacity: 0; transform: translateX(12px); }
}
