/* ============================================================
   WT Lab Inventory — Main Stylesheet
   "Woodman Lab" Hybrid Minimal Design System
   ============================================================ */

/* ---------- Custom Properties ---------- */
:root {
    /* Brand */
    --sidebar-bg: #1e293b;
    --sidebar-text: #f1f5f9;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --accent: #3b82f6;
    --accent-hover: #2563eb;

    /* Surfaces */
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Text */
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-sidebar: #cbd5e1;

    /* Status */
    --success: #22c55e;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --info-border: #bfdbfe;

    /* Layout */
    --sidebar-width: 220px;
    --topbar-height: 48px;
    --radius: 8px;
    --radius-sm: 6px;
    --spacing: 16px;
    --spacing-xs: 8px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);

    /* Fonts */
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

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

/* ---------- Layout: Sidebar + Main ---------- */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 100;
}

.sidebar-brand {
    padding: 16px 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--sidebar-text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand-icon {
    font-size: 1.1rem;
    color: var(--accent);
}

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

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.875rem;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    background: none;
    border-top: none;
    border-right: none;
    border-bottom: none;
    width: 100%;
    text-align: left;
}

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

.sidebar-link.active {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
    border-left-color: var(--sidebar-active);
}

.sidebar-link-icon {
    width: 18px;
    text-align: center;
    font-size: 0.8rem;
}

.sidebar-badge {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text);
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.4;
}

.sidebar-footer {
    padding: 8px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
}

.sidebar-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--sidebar-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--sidebar-text);
}

.sidebar-user-name {
    font-size: 0.8rem;
    color: var(--sidebar-text);
}

/* ---------- Main Content Area ---------- */
.main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* ---------- Top Bar ---------- */
.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-lg);
    position: sticky;
    top: 0;
    z-index: 50;
}

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

.topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

/* ---------- Content Area ---------- */
.content {
    padding: var(--spacing-lg);
    max-width: 1200px;
}

/* ---------- Cards ---------- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

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

.card-link {
    font-size: 0.8rem;
    color: var(--accent);
}

.card-body {
    padding: 20px;
}

.card-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ---------- Stat Row ---------- */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.stat-card-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card--active .stat-card-number {
    color: var(--success);
}

.stat-card--retired .stat-card-number {
    color: var(--text-light);
}

/* ---------- Two-column layout ---------- */
.two-col {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

/* ---------- Quick Actions ---------- */
.quick-actions {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.15s, border-color 0.15s;
}

.quick-action-btn:hover {
    background: var(--card-bg);
    border-color: var(--accent);
    text-decoration: none;
    color: var(--accent);
}

.quick-action-icon {
    width: 24px;
    height: 24px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
}

/* ---------- Tables ---------- */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: var(--bg);
}

.table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.875rem;
    vertical-align: middle;
}

.table tbody tr:hover {
    background: var(--bg);
}

.table--compact td {
    padding: 8px 16px;
}

.table-link {
    font-weight: 500;
}

.table-action {
    color: var(--text-muted);
    text-decoration: none;
    padding: 2px 6px;
    font-size: 0.85rem;
}

.table-action:hover {
    color: var(--accent);
    text-decoration: none;
}

.table-action--danger:hover {
    color: var(--danger);
}

/* ---------- Status Dots ---------- */
.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    text-transform: lowercase;
}

.status-dot::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot--active::before {
    background: var(--success);
}

.status-dot--retired::before {
    background: var(--text-light);
}

.status-dot--decommissioned::before {
    background: var(--text-light);
}

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.3px;
}

.badge--info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid var(--info-border);
}

.badge--warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid var(--warning-border);
}

.badge--danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

.badge--success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    font-family: var(--font);
}

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

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

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

.btn-secondary {
    background: var(--card-bg);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
}

/* ---------- Forms ---------- */
label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.input,
.select,
textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--card-bg);
    transition: border-color 0.15s, box-shadow 0.15s;
}

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

.input--short {
    width: 150px;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* ---------- Filter Bar ---------- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing);
}

.filter-bar .input {
    max-width: 280px;
}

.filter-bar .select {
    max-width: 160px;
}

/* ---------- Modal ---------- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-title {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0 4px;
}

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

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-xs);
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- Login Page ---------- */
.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 100%;
    max-width: 380px;
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.login-card p {
    margin: 0 0 24px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-card label {
    font-weight: 600;
}

.login-card .input {
    padding: 10px 12px;
}

.login-card .btn {
    margin-top: 8px;
    padding: 10px 16px;
}

.login-error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        width: 100%;
        flex-direction: row;
        align-items: center;
        padding: 0 16px;
        height: auto;
    }

    .sidebar-brand {
        border-bottom: none;
        border-right: 1px solid rgba(255, 255, 255, 0.06);
        padding: 8px 12px;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: row;
        padding: 0;
        overflow-x: auto;
    }

    .sidebar-link {
        border-left: none;
        border-bottom: 3px solid transparent;
        padding: 8px 12px;
        white-space: nowrap;
    }

    .sidebar-link.active {
        border-bottom-color: var(--sidebar-active);
        border-left-color: transparent;
    }

    .sidebar-badge {
        display: none;
    }

    .sidebar-footer {
        display: none;
    }

    .main {
        margin-left: 0;
    }

    .two-col {
        grid-template-columns: 1fr;
    }

    .stat-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .content {
        padding: var(--spacing);
    }

    .filter-bar {
        flex-wrap: wrap;
    }

    .filter-bar .input,
    .filter-bar .select {
        max-width: 100%;
        flex: 1;
    }
}
