﻿/* === Reset & Base === */

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

html {
    font-size: var(--text-base);
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading);
    background-color: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
    line-height: 1.25;
    color: var(--text-primary);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }
h5, h6 { font-size: var(--text-base); }

p {
    color: var(--text-secondary);
    line-height: var(--leading);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--duration-base) var(--ease-out);
}

a:hover { color: var(--accent-hover); }

code, pre, kbd {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
}

pre {
    background: var(--bg-surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    overflow-x: auto;
    color: var(--text-primary);
}

hr {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: var(--space-6) 0;
}

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

button, input, select, textarea { font-family: inherit; font-size: inherit; }

:focus-visible {
    outline: 2px solid var(--accent-focus);
    outline-offset: 2px;
}

/* === Buttons === */

.wl-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    height: 34px;
    font-size: var(--text-sm);
    font-weight: 500;
    font-family: var(--font-sans);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--duration-base) var(--ease-out),
                border-color var(--duration-base) var(--ease-out),
                color var(--duration-base) var(--ease-out);
    white-space: nowrap;
    user-select: none;
}

.wl-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.wl-btn-primary { background: var(--accent); color: var(--text-on-accent); border-color: var(--accent); }
.wl-btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.wl-btn-secondary { background: var(--bg-surface-2); color: var(--text-primary); border-color: var(--border-strong); }
.wl-btn-secondary:hover { background: var(--bg-surface-3); }

.wl-btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.wl-btn-ghost:hover { background: var(--bg-surface-2); color: var(--text-primary); }

.wl-btn-danger { background: var(--danger-subtle); color: var(--danger); border-color: var(--danger); }
.wl-btn-danger:hover { background: var(--danger); color: var(--text-on-accent); }

.wl-btn-sm { height: 28px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.wl-btn-lg { height: 42px; padding: 0 var(--space-6); font-size: var(--text-base); }

.wl-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--duration-base) var(--ease-out), color var(--duration-base) var(--ease-out);
}

.wl-icon-btn:hover { background: var(--bg-surface-3); color: var(--text-primary); }
.wl-icon-btn-danger { color: var(--danger); }
.wl-icon-btn-danger:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* === Form Inputs === */

.wl-input,
.wl-select,
.wl-textarea {
    display: block;
    width: 100%;
    background: var(--bg-surface-1);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 0 var(--space-3);
    height: 36px;
    font-size: var(--text-base);
    transition: border-color var(--duration-base) var(--ease-out),
                box-shadow var(--duration-base) var(--ease-out);
}

.wl-textarea {
    height: auto;
    padding: var(--space-2) var(--space-3);
    resize: vertical;
    min-height: 80px;
}

.wl-input::placeholder,
.wl-textarea::placeholder { color: var(--text-muted); }

.wl-input:focus,
.wl-select:focus,
.wl-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-focus);
}

.wl-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.wl-field { display: flex; flex-direction: column; gap: var(--space-1); }

/* === Cards === */

.wl-card {
    background: var(--bg-surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.wl-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
}

.wl-card-body { padding: var(--space-5); }

.wl-card-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-subtle);
}

/* === Tables === */

.wl-table-wrap { width: 100%; overflow-x: auto; }

.wl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.wl-table thead tr { border-bottom: 1px solid var(--border-strong); }

.wl-table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.wl-table td {
    padding: var(--space-3) var(--space-4);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.wl-table tbody tr:last-child td { border-bottom: none; }
.wl-table tbody tr { transition: background var(--duration-fast) var(--ease-out); }
.wl-table tbody tr:hover { background: var(--bg-surface-2); }
.wl-table td strong, .wl-table td .wl-text-primary { color: var(--text-primary); }

/* === Badges === */

.wl-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-sm);
    letter-spacing: 0.02em;
}

.wl-badge-success { background: var(--success-subtle); color: var(--success); }
.wl-badge-warning { background: var(--warning-subtle); color: var(--warning); }
.wl-badge-danger  { background: var(--danger-subtle);  color: var(--danger); }
.wl-badge-info    { background: var(--info-subtle);    color: var(--info); }
.wl-badge-neutral { background: var(--bg-surface-2);   color: var(--text-muted); }

.wl-badge-dot::before {
    content: "";
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* === Status Indicator === */

.wl-status {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
}

.wl-status::before {
    content: "";
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--status-offline);
}

.wl-status-online::before  { background: var(--status-online); }
.wl-status-warning::before { background: var(--status-warning); }

/* === Layout Primitives === */

.wl-stack { display: flex; flex-direction: column; }
.wl-stack-1 { gap: var(--space-1); }
.wl-stack-2 { gap: var(--space-2); }
.wl-stack-3 { gap: var(--space-3); }
.wl-stack-4 { gap: var(--space-4); }
.wl-stack-6 { gap: var(--space-6); }
.wl-stack-8 { gap: var(--space-8); }

.wl-cluster { display: flex; flex-wrap: wrap; align-items: center; }
.wl-cluster-2 { gap: var(--space-2); }
.wl-cluster-3 { gap: var(--space-3); }
.wl-cluster-4 { gap: var(--space-4); }

.wl-between { justify-content: space-between; }
.wl-end     { justify-content: flex-end; }
.wl-center  { justify-content: center; }

/* === Utility === */

.wl-text-primary   { color: var(--text-primary); }
.wl-text-secondary { color: var(--text-secondary); }
.wl-text-muted     { color: var(--text-muted); }
.wl-text-accent    { color: var(--accent); }
.wl-text-success   { color: var(--success); }
.wl-text-warning   { color: var(--warning); }
.wl-text-danger    { color: var(--danger); }

.wl-text-xs   { font-size: var(--text-xs); }
.wl-text-sm   { font-size: var(--text-sm); }
.wl-text-base { font-size: var(--text-base); }
.wl-text-lg   { font-size: var(--text-lg); }
.wl-text-xl   { font-size: var(--text-xl); }
.wl-text-2xl  { font-size: var(--text-2xl); }

.wl-font-medium   { font-weight: 500; }
.wl-font-semibold { font-weight: 600; }
.wl-font-bold     { font-weight: 700; }
.wl-font-mono     { font-family: var(--font-mono); }

.wl-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* === Page Shell === */

.wl-page { min-height: 100vh; background: var(--bg-base); }

.wl-container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

/* === Scrollbar === */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-lg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Modal === */

.wl-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    background: rgba(0, 0, 0, 0.55);
    align-items: center;
    justify-content: center;
}

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

.wl-modal {
    background: var(--bg-surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wl-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.wl-modal-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
}

.wl-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast) var(--ease-out);
}

.wl-modal-close:hover { color: var(--text-primary); }

.wl-modal-body {
    padding: var(--space-5);
    overflow-y: auto;
    flex: 1;
}

.wl-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.wl-form-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin-bottom: var(--space-4);
}

.wl-form-row:last-child { margin-bottom: 0; }

.wl-label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
}
