/* Write Suite — Modern Dark Theme */

/* ─── Variables & Theme Overrides ───────────────────────────────── */
:root {
    /* Font Stack */
    --pico-font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Palette: Slate / Indigo / Violet */
    --pico-background-color: #0f172a;
    /* Slate 900 */
    --pico-card-background-color: #1e293b;
    /* Slate 800 */
    --pico-color: #f8fafc;
    /* Slate 50 */
    --pico-muted-color: #94a3b8;
    /* Slate 400 */
    --pico-border-color: #334155;
    /* Slate 700 */
    --pico-muted-border-color: #334155;

    /* Primary: Indigo 500 */
    --pico-primary: #6366f1;
    --pico-primary-background: #6366f1;
    --pico-primary-hover: #4f46e5;
    --pico-primary-hover-background: #4f46e5;
    --pico-primary-underline: rgba(99, 102, 241, 0.5);
    --pico-primary-inverse: #fff;

    /* Secondary: Slate 600 */
    --pico-secondary: #475569;
    --pico-secondary-background: #475569;
    --pico-secondary-hover: #334155;
    --pico-secondary-hover-background: #334155;
    --pico-secondary-inverse: #fff;

    /* UI Measurements */
    --sidebar-width: 260px;
    --header-height: 64px;
    --border-radius: 12px;
}

/* ─── Global Reset & Base ────────────────────────────────────────── */
body {
    background: var(--pico-background-color);
    color: var(--pico-color);
    font-family: var(--pico-font-family);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    letter-spacing: -0.025em;
    color: #fff;
}

a {
    transition: color 0.2s, background-color 0.2s;
}

/* Glassmorphism utility */
.glass {
    background: rgba(30, 41, 59, 0.7) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
}

/* ─── Layout: sidebar + content ─────────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
}

nav.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    padding: 1.5rem;
    background: var(--pico-card-background-color);
    border-right: 1px solid var(--pico-border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

nav.sidebar .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 2rem;
    padding-bottom: 0;
    text-decoration: none;
    color: #fff;
    letter-spacing: -0.025em;
}

nav.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

nav.sidebar ul li {
    padding: 0;
    margin: 0;
}

nav.sidebar ul li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--pico-muted-color);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    background: transparent;
    border: 1px solid transparent;
}

nav.sidebar ul li a:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
}

nav.sidebar ul li a.active {
    background: var(--pico-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
    font-weight: 600;
}

nav.sidebar .nav-icon {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

nav.sidebar footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--pico-border-color);
}

nav.sidebar footer button {
    width: 100%;
    padding: 0.6rem;
    font-size: 0.9rem;
    background: transparent;
    border: 1px solid var(--pico-border-color);
    color: var(--pico-muted-color);
    border-radius: 8px;
    transition: all 0.2s;
}

nav.sidebar footer button:hover {
    border-color: var(--pico-muted-color);
    color: #fff;
}

.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2.5rem 3rem;
    max-width: 1400px;
    width: 100%;
}

/* ─── Breadcrumb ────────────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--pico-muted-color);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.breadcrumb a {
    color: var(--pico-muted-color);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: #fff;
}

.breadcrumb i {
    font-size: 1rem;
}

.breadcrumb .sep {
    opacity: 0.3;
    font-size: 0.8rem;
}

/* ─── Page Header ───────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.8rem;
    margin: 0;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ─── Badges ────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
}

.badge-pending {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.badge-running {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-completed {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-failed {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ─── Unified Card Styles ───────────────────────────────────────── */
.card,
.stat-card,
.site-card,
.config-section {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card:hover,
.stat-card:hover,
.site-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-color: #475569;
}

/* ─── Stats Grid ────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    border-top: 4px solid var(--pico-primary);
    display: flex;
    flex-direction: column;
}

.stat-card .stat-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    color: var(--pico-muted-color);
    font-size: 0.85rem;
    font-weight: 500;
}

.stat-card .stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.25rem;
    line-height: 1;
}

/* ─── Tables ────────────────────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
}

table th {
    background: rgba(30, 41, 59, 0.5);
    color: var(--pico-muted-color);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--pico-border-color);
    padding: 1rem;
}

table td {
    padding: 1rem;
    border-bottom: 1px solid var(--pico-border-color);
    font-size: 0.95rem;
    vertical-align: middle;
}

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

table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* ─── Buttons ───────────────────────────────────────────────────── */
button,
.btn {
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
    font-family: inherit;
}

.btn-launch {
    background: var(--pico-primary);
    border: none;
    color: #fff;
    padding: 0.6rem 1.25rem;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-launch:hover {
    background: var(--pico-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

/* ─── Modal ─────────────────────────────────────────────────────── */
#modal-container dialog {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    width: 600px;
    max-width: 90vw;
    height: 520px;
    max-height: 80vh;
    padding: 0;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    animation: modal-in 0.3s ease-out;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#modal-container dialog::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

#modal-container dialog form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--pico-border-color);
    background: rgba(15, 23, 42, 0.3);
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 1.1rem;
    color: #fff;
    margin: 0;
    flex: 1;
}

.modal-close {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--pico-border-color) !important;
    padding: 0;
    color: var(--pico-muted-color);
    transition: all 0.2s;
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.modal-close:hover {
    color: #fff;
    background: rgba(239, 68, 68, 0.2) !important;
    border: 1px solid rgba(239, 68, 68, 0.5) !important;
    transform: scale(1.05);
}

.modal-close i {
    font-size: 1.5rem;
}

#dynamic-params {
    transition: opacity 0.2s ease;
    min-height: 0;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    max-height: calc(520px - 140px); /* hauteur totale - header - footer */
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--pico-border-color);
    background: rgba(15, 23, 42, 0.3);
    flex-shrink: 0;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ─── Forms ─────────────────────────────────────────────────────── */
input,
select,
textarea {
    background: #0f172a !important;
    border: 1px solid var(--pico-border-color) !important;
    border-radius: 8px !important;
    color: #fff !important;
    padding: 0.6rem 1rem !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--pico-primary) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2) !important;
}

label {
    color: var(--pico-muted-color);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
}

/* ─── Code / Logs ───────────────────────────────────────────────── */
.log-container,
.json-view,
.prompt-editor textarea {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: #0f172a;
    border: 1px solid var(--pico-border-color);
    border-radius: 8px;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.3);
}

/* ─── Utilities ─────────────────────────────────────────────────── */
.text-muted {
    color: var(--pico-muted-color);
}

.text-success {
    color: #4ade80;
}

.text-danger {
    color: #f87171;
}

.text-warning {
    color: #fbbf24;
}

/* ─── Sites Grid Details ────────────────────────────────────────── */
.sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.site-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.site-card-header {
    border-bottom: 1px solid var(--pico-border-color);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.site-card-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--pico-border-color);
}