/* ===== Theme Variables ===== */

/* Default: LIGHT THEME */
:root {
    --bg: #f6f7fb;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;

    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --ring: rgba(37, 99, 235, 0.35);

    --shadow: 0 6px 24px rgba(2, 6, 23, 0.08);
    --radius: 12px;

    --border: #e5e7eb;
    --input: #ffffff;

    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
}

/* DARK THEME */
html[data-theme="dark"] {
    --bg: #0b1220;
    --card: #0f172a;
    --text: #e5e7eb;
    --muted: #94a3b8;

    --primary: #3b82f6;
    --primary-600: #2563eb;
    --ring: rgba(59, 130, 246, 0.35);

    --shadow: 0 6px 24px rgba(2, 6, 23, 0.35);
    --radius: 12px;

    --border: #1f2937;
    --input: #111827;

    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
}

/* Optional: smooth theme transition */
html {
    transition: background-color 0.2s ease, color 0.2s ease;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

/* ===== Your existing styles keep using vars ===== */
body {
    font-family: system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    margin: 0;
    padding: 2rem;
    line-height: 1.35;
}

/* Container to center content on large screens */
.container {
    max-width: 1100px;
    margin-inline: auto;
}

.card {
    background: var(--card);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    box-shadow: var(--shadow);
}

/* Typography */
h1 {
    margin: 0 0 0.5rem 0;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-size: clamp(1.25rem, 1.6vw + 1rem, 2rem);
}
h2 {
    margin: 0 0 0.5rem 0;
    font-weight: 600;
    font-size: clamp(1.1rem, 1.2vw + 0.9rem, 1.5rem);
    color: var(--text);
}
p,
label,
small {
    color: var(--text);
}
small,
.muted {
    color: var(--muted);
}

/* Layout utils */
.flex {
    display: flex;
    gap: 0.5rem;
}
.row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.col {
    flex: 1 1 260px;
}

/* controls */
input,
textarea,
select {
    width: 100%;
    padding: 0.5rem 0.6rem;
    margin: 0.25rem 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease,
        background-color 0.2s ease, color 0.2s ease;
    font: inherit;
}
input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}

button {
    width: auto;
    padding: 0.55rem 0.9rem;
    margin: 0.25rem 0;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.05s ease, box-shadow 0.15s ease,
        background 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
button:hover {
    background: var(--primary-600);
}
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

/* layout helpers */
.button-row,
.button-row-top {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.button-row-top {
    align-items: flex-start;
}
.button-row > *,
.button-row-top > * {
    width: auto;
}

/* Scrollable table container */
.table-scroll {
    max-height: 340px; /* adjust to taste */
    overflow: auto; /* shows scrollbar when needed */
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
}

/* Ensure table plays nicely inside the container */
.table-scroll table {
    width: 100%;
    border-collapse: collapse;
    margin: 0; /* remove extra gaps */
}

/* Keep headers visible while body scrolls */
.table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card);
    box-shadow: 0 1px 0 var(--border);
}

/* Optional: nicer scrollbar */
.table-scroll::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}
.table-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 8px;
}
.table-scroll::-webkit-scrollbar-track {
    background: transparent;
}

/* Code / logs */
pre {
    white-space: pre-wrap;
    font-size: 0.85rem;
    background: #111;
    color: #0f0;
    padding: 1rem;
    border-radius: 8px;
    overflow: auto;
    margin: 0.5rem 0 0 0;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}
th,
td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}
th {
    font-weight: 700;
    color: var(--muted);
}

/* Inline status badges / labels */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    font-size: 0.8rem;
    background: #eef2ff;
    color: #3730a3;
}

/* Form section grouping */
.field-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.field {
    display: flex;
    flex-direction: column;
}

/* Spacing helpers */
.mt-0 {
    margin-top: 0;
}
.mt-2 {
    margin-top: 0.5rem;
}
.mt-3 {
    margin-top: 0.75rem;
}
.mt-4 {
    margin-top: 1rem;
}
.mb-0 {
    margin-bottom: 0;
}
.mb-2 {
    margin-bottom: 0.5rem;
}

/* Visibility helpers */
.hidden {
    display: none !important;
}

/* Truncate long labels */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Responsive */
@media (max-width: 900px) {
    .container {
        padding-inline: 0.25rem;
    }
    .field-group {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 640px) {
    body {
        padding: 1rem;
    }
    .button-row,
    .button-row-top {
        gap: 0.4rem;
    }
    .button-row > button,
    .button-row-top > button {
        flex: 0 1 auto;
    }
}
