/* ============================================================
   Task Assigner — Main Stylesheet
   ============================================================ */

/* ── Custom properties ────────────────────────────────────── */
:root {
    --color-primary:      #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-primary-light:#eff6ff;
    --color-accent:       #7c3aed;

    --color-success:      #16a34a;
    --color-success-bg:   #f0fdf4;
    --color-error:        #dc2626;
    --color-error-bg:     #fef2f2;
    --color-warning:      #d97706;
    --color-warning-bg:   #fffbeb;
    --color-info:         #0284c7;
    --color-info-bg:      #f0f9ff;

    --color-bg:           #f8fafc;
    --color-surface:      #ffffff;
    --color-border:       #e2e8f0;
    --color-border-focus: #93c5fd;

    --color-text:         #1e293b;
    --color-text-muted:   #64748b;
    --color-text-light:   #94a3b8;

    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg:  12px;
    --radius-xl:  16px;

    --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
    --shadow-md:  0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
    --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);

    --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
    --font-mono:  'JetBrains Mono', 'Fira Code', monospace;

    --sidebar-w:  240px;
    --topbar-h:   60px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-text);
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

p { margin-bottom: .75rem; }
p:last-child { margin-bottom: 0; }

/* ── Layout — public pages ────────────────────────────────── */
.page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 1.5rem;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.page-header .brand {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -.3px;
}

.page-header .brand span { color: var(--color-primary); }

.page-content {
    flex: 1;
    padding: 2.5rem 1.5rem;
    max-width: 860px;
    margin: 0 auto;
    width: 100%;
}

.page-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: .8125rem;
    color: var(--color-text-muted);
}

/* ── Admin layout ─────────────────────────────────────────── */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: #1e293b;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 200;
    transition: transform .25s ease;
}

.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-brand h1 {
    font-size: 1rem;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -.2px;
}

.sidebar-brand p {
    font-size: .75rem;
    color: #64748b;
    margin-top: .125rem;
    margin-bottom: 0;
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .625rem 1.25rem;
    font-size: .875rem;
    color: #94a3b8;
    transition: background .15s, color .15s;
    border-radius: 0;
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,.06);
    color: #f1f5f9;
}

.sidebar-nav a.active {
    border-left: 3px solid var(--color-primary);
    padding-left: calc(1.25rem - 3px);
}

.sidebar-nav .nav-icon {
    width: 18px;
    height: 18px;
    opacity: .75;
    flex-shrink: 0;
}

.sidebar-nav a.active .nav-icon,
.sidebar-nav a:hover .nav-icon { opacity: 1; }

.sidebar-section {
    padding: .375rem 1.25rem .125rem;
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #475569;
    margin-top: .5rem;
}

.sidebar-footer {
    padding: .875rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.07);
    font-size: .8rem;
    color: #475569;
}

/* Main content area */
.admin-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Top bar */
.topbar {
    height: var(--topbar-h);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.topbar-user {
    font-size: .8125rem;
    color: var(--color-text-muted);
}

/* Page body */
.admin-body {
    padding: 1.75rem;
    flex: 1;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.card-body { padding: 1.5rem; }

/* ── Stat cards (dashboard) ──────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

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

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1;
    margin-bottom: .25rem;
}

.stat-label {
    font-size: .8125rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .5rem 1rem;
    font-size: .875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
    font-family: inherit;
}

.btn:hover { text-decoration: none; }

.btn-sm { padding: .3125rem .75rem; font-size: .8125rem; }
.btn-lg { padding: .6875rem 1.375rem; font-size: 1rem; }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn-primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: #fff;
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-secondary:hover {
    background: var(--color-bg);
    border-color: #c0ccd8;
    color: var(--color-text);
}

.btn-danger {
    background: var(--color-error);
    color: #fff;
    border-color: var(--color-error);
}
.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}

.btn-success {
    background: var(--color-success);
    color: #fff;
    border-color: var(--color-success);
}
.btn-success:hover {
    background: #15803d;
    border-color: #15803d;
    color: #fff;
}

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.btn-outline:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--color-text-muted);
}
.btn-ghost:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-icon {
    padding: .375rem;
    border-radius: var(--radius-sm);
}

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: .375rem;
}

.form-label .required {
    color: var(--color-error);
    margin-left: .125rem;
}

.form-control,
.form-select {
    display: block;
    width: 100%;
    padding: .5625rem .875rem;
    font-size: .9375rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
    line-height: 1.5;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

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

.form-hint {
    font-size: .8125rem;
    color: var(--color-text-muted);
    margin-top: .25rem;
}

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

.form-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    margin-top: 1.5rem;
}

/* File input */
.file-drop {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.file-drop:hover,
.file-drop.drag-over {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}
.file-drop input[type="file"] {
    display: none;
}
.file-drop-label { font-size: .9375rem; color: var(--color-text-muted); }
.file-drop-label strong { color: var(--color-primary); }
.file-drop-hint { font-size: .8125rem; color: var(--color-text-light); margin-top: .375rem; }
.file-name-display { margin-top: .625rem; font-size: .875rem; font-weight: 500; color: var(--color-text); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

thead th {
    padding: .75rem 1rem;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    text-align: left;
}

tbody td {
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: #fafbfc; }

.td-task-id {
    font-family: var(--font-mono);
    font-size: .8125rem;
    font-weight: 600;
    color: var(--color-primary);
    letter-spacing: .04em;
}

.td-url {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-actions {
    display: flex;
    align-items: center;
    gap: .375rem;
}

/* ── Badges / Status ──────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .1875rem .625rem;
    font-size: .75rem;
    font-weight: 600;
    border-radius: 999px;
    letter-spacing: .02em;
    white-space: nowrap;
}

.badge-pending     { background: #fef3c7; color: #92400e; }
.badge-in-progress { background: #dbeafe; color: #1e40af; }
.badge-completed   { background: #d1fae5; color: #065f46; }
.badge-on-hold     { background: #f3f4f6; color: #374151; }
.badge-cancelled   { background: #fee2e2; color: #991b1b; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .875rem 1.125rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: .9rem;
    border: 1px solid transparent;
}

.alert-success { background: var(--color-success-bg); color: #14532d; border-color: #bbf7d0; }
.alert-error   { background: var(--color-error-bg);   color: #7f1d1d; border-color: #fecaca; }
.alert-warning { background: var(--color-warning-bg); color: #78350f; border-color: #fde68a; }
.alert-info    { background: var(--color-info-bg);    color: #0c4a6e; border-color: #bae6fd; }

/* ── Filters / Search bar ─────────────────────────────────── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-end;
    margin-bottom: 1.25rem;
}

.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }
.filter-bar .form-control,
.filter-bar .form-select { min-width: 0; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: .375rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.pagination-info {
    font-size: .8125rem;
    color: var(--color-text-muted);
    margin-right: auto;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 .5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    font-size: .8125rem;
    color: var(--color-text);
    background: var(--color-surface);
    text-decoration: none;
    transition: background .15s, border-color .15s;
}

.page-link:hover {
    background: var(--color-bg);
    text-decoration: none;
}

.page-link.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.page-link.disabled {
    opacity: .4;
    pointer-events: none;
}

/* ── Login page ───────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 60%, #f0fdf4 100%);
    padding: 1.5rem;
}

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

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

.login-logo h1 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--color-text);
}

.login-logo h1 span { color: var(--color-primary); }

.login-logo p {
    font-size: .875rem;
    color: var(--color-text-muted);
    margin-top: .25rem;
}

/* ── Public task page ─────────────────────────────────────── */
.task-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.task-card-header {
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    color: #fff;
}

.task-card-header .task-id-label {
    font-size: 1.625rem;
    font-weight: 600;
    letter-spacing: -.01em;
    opacity: 1;
    margin-bottom: .375rem;
    line-height: 1.25;
}

.task-card-header .task-status {
    margin-top: .75rem;
}

.task-card-body {
    padding: 2rem;
}

.task-section {
    margin-bottom: 1.75rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--color-border);
}

.task-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.task-section-label {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: .625rem;
}

.task-section-value {
    color: var(--color-text);
    line-height: 1.7;
}

.task-section-value a {
    color: var(--color-primary);
    word-break: break-all;
}

.task-description {
    line-height: 1.8;
}

.task-description p  { margin-bottom: .75rem; }
.task-description ul,
.task-description ol { padding-left: 1.5rem; margin-bottom: .75rem; }
.task-description li { margin-bottom: .25rem; }

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.25rem 2rem;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    font-size: .8125rem;
    color: var(--color-text-muted);
}

/* ── Error page ───────────────────────────────────────────── */
.error-page {
    text-align: center;
    padding: 4rem 1.5rem;
}

.error-page .error-code {
    font-size: 5rem;
    font-weight: 800;
    color: var(--color-border);
    line-height: 1;
    margin-bottom: .5rem;
}

.error-page h2 {
    font-size: 1.5rem;
    color: var(--color-text);
    margin-bottom: .75rem;
}

.error-page p {
    color: var(--color-text-muted);
    max-width: 480px;
    margin: 0 auto 1.5rem;
}

/* ── Import summary ──────────────────────────────────────── */
.import-summary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.import-stat {
    text-align: center;
    padding: 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.import-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: .25rem;
}

.import-stat-label {
    font-size: .75rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.import-stat.stat-imported .import-stat-value { color: var(--color-success); }
.import-stat.stat-updated  .import-stat-value { color: var(--color-info); }
.import-stat.stat-skipped  .import-stat-value { color: var(--color-warning); }
.import-stat.stat-failed   .import-stat-value { color: var(--color-error); }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 1.5rem;
    color: var(--color-text-muted);
}

.empty-state svg {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    opacity: .35;
}

.empty-state h3 {
    font-size: 1.125rem;
    color: var(--color-text);
    margin-bottom: .375rem;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-backdrop.open { display: flex; }

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-width: 440px;
    width: 100%;
    overflow: hidden;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body { padding: 1.5rem; }

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
}

/* ── Misc helpers ─────────────────────────────────────────── */
.text-muted { color: var(--color-text-muted); }
.text-sm    { font-size: .875rem; }
.text-xs    { font-size: .75rem; }
.font-mono  { font-family: var(--font-mono); }
.font-bold  { font-weight: 700; }
.mt-1  { margin-top: .25rem; }
.mt-2  { margin-top: .5rem; }
.mt-4  { margin-top: 1rem; }
.mb-1  { margin-bottom: .25rem; }
.mb-4  { margin-bottom: 1rem; }
.mb-6  { margin-bottom: 1.5rem; }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.ml-auto { margin-left: auto; }

/* ── Responsive — mobile sidebar ────────────────────────── */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: .375rem;
    color: var(--color-text);
    border-radius: var(--radius-sm);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 199;
}

@media (max-width: 768px) {
    :root { --sidebar-w: 260px; }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open { display: block; }

    .admin-main { margin-left: 0; }

    .sidebar-toggle { display: flex; }

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

    .topbar { padding: 0 1rem; }

    .admin-body { padding: 1rem; }

    .card-header { flex-direction: column; align-items: flex-start; }

    .filter-bar { flex-direction: column; }
    .filter-bar .form-group { width: 100%; }

    .task-card-body { padding: 1.25rem; }
    .task-card-header { padding: 1.25rem; }
    .task-meta { padding: 1rem 1.25rem; }

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

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .import-summary { grid-template-columns: 1fr 1fr; }
}
