/* LabyrinthLogin Portal — functional styling */

:root {
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-text: #212529;
    --color-text-muted: #6c757d;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-success: #16a34a;
    --color-warn: #d97706;
    --color-error: #dc2626;
    --color-danger: #dc2626;
    --color-border: #dee2e6;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Navbar --- */

.navbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-primary);
    text-decoration: none;
}

.nav-links { display: flex; align-items: center; gap: 1.25rem; }
.nav-links a { color: var(--color-text); text-decoration: none; font-size: 0.9rem; }
.nav-links a:hover, .nav-links a.active { color: var(--color-primary); }
.nav-links a.active { font-weight: 600; }
.nav-user { color: var(--color-text-muted); font-size: 0.85rem; }
.nav-divider { width: 1px; height: 1.2rem; background: var(--color-border); }

/* --- Layout --- */

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
}

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

/* --- Page header --- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.page-description {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* --- Buttons --- */

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
}

.btn:hover { background: var(--color-bg); }
.btn-primary { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: transparent; }
.btn-success { background: #16a34a; color: white; border-color: #16a34a; }
.btn-success:hover { background: #15803d; }
.btn-danger { color: var(--color-danger); border-color: var(--color-danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }

/* --- Forms --- */

.form-page { max-width: 560px; margin: 0 auto; }

.form { margin-top: 1.5rem; }

.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.help-text { display: block; color: var(--color-text-muted); font-size: 0.8rem; margin-top: 0.2rem; }
.error { display: block; color: var(--color-error); font-size: 0.8rem; margin-top: 0.2rem; }

fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

fieldset legend {
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0 0.5rem;
}

.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.form-footer { margin-top: 1rem; text-align: center; font-size: 0.9rem; }

/* --- Tables --- */

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table th,
.table td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.85rem;
}

.table th {
    background: var(--color-bg);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--color-text-muted);
}

.table td.actions { white-space: nowrap; }

.table-compact th,
.table-compact td {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
}

/* --- Cards --- */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.card-header h3 { font-size: 1rem; }

.card-body {
    padding: 1rem;
}

.card-body p {
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
}

.card-actions {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 0.5rem;
}

/* --- Stats grid (dashboard) --- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

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

.stat-number { font-size: 2rem; font-weight: 700; color: var(--color-primary); }
.stat-label { font-size: 0.85rem; color: var(--color-text-muted); margin-bottom: 0.5rem; }
.stat-link { font-size: 0.8rem; }

/* --- Detail grid --- */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 2rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.detail-item { font-size: 0.9rem; }
.detail-label { display: block; font-weight: 600; font-size: 0.8rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.02em; }

/* --- Config select cards (deployment creation) --- */

.config-select-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
}

.config-select-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--color-bg);
    cursor: pointer;
    font-weight: normal;
}

.config-select-header input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
}

.config-select-devices {
    padding: 0;
}

/* --- Badges --- */

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-ok { background: #dcfce7; color: var(--color-success); }
.badge-warn { background: #fef3c7; color: var(--color-warn); }
.badge-info { background: #dbeafe; color: var(--color-primary); }
.badge-neutral { background: #f3f4f6; color: var(--color-text-muted); }
.badge-heartbeat { background: #dbeafe; color: var(--color-primary); }
.badge-usb { background: #f3e8ff; color: #7c3aed; }

/* --- Alerts / Messages --- */

.messages { margin-bottom: 1.5rem; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.alert a { color: inherit; font-weight: 600; }

.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* --- Hero (landing page) --- */

.hero {
    text-align: center;
    padding: 4rem 0 3rem;
}

.hero h1 { font-size: 2.5rem; margin-bottom: 0.75rem; }
.hero-subtitle { font-size: 1.15rem; color: var(--color-text-muted); max-width: 600px; margin: 0 auto 2rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; }

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.feature {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.feature h3 { margin-bottom: 0.5rem; font-size: 1rem; }
.feature p { font-size: 0.9rem; color: var(--color-text-muted); }

/* --- Dashboard --- */

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.quick-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.section { margin-bottom: 2.5rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section h3 { margin-bottom: 1rem; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.empty-state p { margin-bottom: 1rem; }

/* --- Breadcrumb --- */

.breadcrumb { font-size: 0.85rem; color: var(--color-text-muted); margin-bottom: 1rem; }
.breadcrumb a { color: var(--color-primary); text-decoration: none; }

/* --- Device detail --- */

.device-actions { margin-bottom: 2rem; display: flex; gap: 0.75rem; }

/* --- Success card (download pages) --- */

.success-card {
    background: var(--color-surface);
    border: 2px solid var(--color-success);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    margin-bottom: 2rem;
}

.success-card p { margin-bottom: 0.75rem; }

.instructions { padding-left: 1.5rem; }
.instructions li { margin-bottom: 0.5rem; font-size: 0.9rem; }

.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-family: "Cascadia Code", "Fira Code", monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre;
}

/* --- Utilities --- */

.monospace { font-family: "Cascadia Code", "Fira Code", monospace; font-size: 0.85em; }
.text-muted { color: var(--color-text-muted); }
.info-text { color: var(--color-text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

/* --- Annotation sidebar (configuration form) --- */

.form-with-annotations {
    position: relative;
    max-width: 560px;
    margin: 0 auto;
}

.form-with-annotations .form-page {
    max-width: none;
    margin: 0;
}

@media (min-width: 900px) {
    .annotation-sidebar {
        position: absolute;
        top: 0;
        width: 260px;
    }
    .annotation-sidebar-right {
        left: calc(100% + 2rem);
    }
    .annotation-sidebar-left {
        right: calc(100% + 2rem);
    }
}

@media (max-width: 899px) {
    .annotation-sidebar-left {
        display: none;
    }
    .annotation-sidebar-right {
        margin-top: 2rem;
    }
}

.annotation {
    padding: 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    line-height: 1.5;
    border-left: 3px solid;
    transition: top 0.3s ease, opacity 0.2s;
}

.annotation-info {
    background: #eff6ff;
    border-left-color: #2563eb;
    color: #1e40af;
}

.annotation-warning {
    background: #fef3c7;
    border-left-color: #d97706;
    color: #92400e;
}

.annotation-critical {
    background: #fee2e2;
    border-left-color: #dc2626;
    color: #991b1b;
}

.annotation-badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
    opacity: 0.7;
}

.annotation-message {
    font-weight: 500;
}

.annotation-detail {
    margin-top: 0.3rem;
    opacity: 0.85;
}

.annotation-empty {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    padding: 1rem 0;
}

/* --- Tier selector (dev) --- */
.tier-select {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    background: var(--color-surface);
    cursor: pointer;
}

/* --- Topology tile selector --- */
.topology-selector {
    margin-bottom: 1.5rem;
}

.topology-tile {
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.25s, transform 0.2s, background 0.25s, opacity 0.25s;
    border: 2px solid transparent;
    text-decoration: none;
}

.topology-tile:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.topology-tile.selected {
    border-color: var(--color-primary);
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.18),
        0 8px 24px rgba(37, 99, 235, 0.18),
        0 2px 8px rgba(0, 0, 0, 0.06);
    transform: translateY(-3px);
}

.topology-tile.selected .stat-number {
    color: var(--color-primary);
}

.topology-tile.selected .stat-label {
    color: var(--color-primary);
    opacity: 0.85;
}

/* --- Config form body reveal --- */
.config-form-body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.5s ease, opacity 0.4s ease, margin-top 0.3s ease;
    margin-top: 0;
}

.config-form-body.visible {
    max-height: 4000px;
    opacity: 1;
    margin-top: 1.5rem;
}

/* --- Modal overlay --- */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    padding: 2rem;
    max-width: 480px;
    width: 90%;
}

.modal-card h3 { margin-bottom: 1rem; }
.modal-card p { margin-bottom: 0.5rem; font-size: 0.95rem; }

.modal-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.modal-purchase-msg {
    color: var(--color-error);
    font-weight: 500;
    margin-bottom: 0.5rem !important;
}

/* --- License bar (profile page) --- */

.license-bar-track {
    background: var(--color-border);
    border-radius: 4px;
    height: 8px;
    width: 100%;
    overflow: hidden;
}

.license-bar-fill {
    background: var(--color-primary);
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
    min-width: 0;
    max-width: 100%;
}

.license-bar-fill.license-bar-over {
    background: var(--color-error);
    max-width: 100%;
}

/* --- Checkout form (inside modals) --- */

.modal-card-wide {
    max-width: 560px;
}

.checkout-section {
    margin-top: 1rem;
}

.checkout-summary {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.checkout-summary h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.checkout-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    font-size: 0.9rem;
}

.checkout-divider {
    border-top: 1px solid var(--color-border);
    margin: 0.5rem 0;
}

.checkout-total {
    font-weight: 600;
    font-size: 1rem;
}

.checkout-form h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.checkout-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s;
}

.checkout-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

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