/* ══════════════════════════════════════════════════════
   MelTuc Shared Component Library
   Full CSS from MELTUC-THEME-UI-STANDARDS.md
   ══════════════════════════════════════════════════════ */

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Geist Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
}

h1, h2, h3, h4 {
    font-family: 'Barlow Condensed', sans-serif;
    letter-spacing: 0.05em;
}

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

[hidden] { display: none !important; }

/* ── Page Shell (Sidebar + Main) ── */
.page-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 220px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: margin-left 0.2s ease;
    overflow-y: auto;
}
.sidebar.collapsed { margin-left: -220px; }

.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 2px;
    text-decoration: none;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.page-body {
    padding: 24px 28px 48px;
    overflow-y: auto;
    flex: 1;
}

/* ── Sticky Top Nav (Public Pages) ── */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(13, 17, 23, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.top-nav-logo {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 2px;
    text-decoration: none;
}

.top-nav-links {
    display: flex;
    gap: 24px;
    align-items: center;
}

.top-nav-link {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}
.top-nav-link:hover { color: var(--text); text-decoration: none; }

/* ── Sidebar Navigation ── */
.nav-section {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.nav-label {
    padding: 8px 16px 4px;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
}

.nav-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    text-decoration: none;
}

.nav-link.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: rgba(0, 212, 170, 0.08);
}

/* ── Page Header Bar ── */
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-square {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.icon-square.teal  { background: var(--accent); color: var(--bg); }
.icon-square.amber { background: var(--amber); color: var(--bg); }
.icon-square.red   { background: var(--danger); color: var(--text); }

.page-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.page-subtitle {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

/* ── Cards / Panels ── */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.card:hover {
    border-color: rgba(0, 212, 170, 0.3);
}

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

.card-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ── Stat Tiles ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-tile {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.stat-label {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.stat-value {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.stat-value.teal  { color: var(--accent); }
.stat-value.amber { color: var(--amber); }
.stat-value.red   { color: var(--danger); }

/* ── Data Tables / Grids ── */
.data-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-grid th {
    padding: 12px 10px;
    text-align: left;
    font-size: 10px;
    font-weight: 400;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-grid td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.data-grid tr:nth-child(even) td {
    background: rgba(26, 31, 46, 0.30);
}

.data-grid tr:hover td {
    background: rgba(30, 37, 48, 0.80);
    cursor: pointer;
}

.data-grid td.muted { color: var(--muted); }
.data-grid td.teal  { color: var(--accent); }
.data-grid td.amber { color: var(--amber); }
.data-grid td.red   { color: var(--danger); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-family: 'Geist Mono', monospace;
    font-size: 12px;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s ease;
    white-space: nowrap;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-teal    { background: var(--accent); color: var(--bg); }
.btn-amber   { background: var(--amber); color: var(--bg); }
.btn-danger  { background: var(--danger); color: var(--text); }
.btn-success { background: var(--success); color: var(--bg); }
.btn-info    { background: var(--info); color: var(--bg); }
.btn-muted   { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-ghost   { background: transparent; color: var(--muted); }

.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }

/* ── Badges & Pills ── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 400;
    white-space: nowrap;
}

.badge-teal    { background: rgba(0, 212, 170, 0.15); color: var(--accent); }
.badge-amber   { background: rgba(245, 158, 11, 0.15); color: var(--amber); }
.badge-red     { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-green   { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-gray    { background: rgba(107, 114, 128, 0.15); color: var(--gray-medium); }
.badge-blue    { background: rgba(96, 165, 250, 0.15); color: var(--info); }

.badge-p0 { background: rgba(239, 68, 68, 0.2);   color: var(--danger); }
.badge-p1 { background: rgba(245, 158, 11, 0.2);  color: var(--amber); }
.badge-p2 { background: rgba(234, 179, 8, 0.2);   color: #eab308; }
.badge-p3 { background: rgba(107, 114, 128, 0.2);  color: var(--gray-medium); }

/* ── Form Inputs ── */
.input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    color: var(--text);
    font-family: 'Geist Mono', monospace;
    font-size: 12px;
    width: 100%;
    outline: none;
    transition: border-color 0.15s ease;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--gray-dark); }

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

select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892a4' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.input-label {
    display: block;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 6px;
}

.input-group {
    margin-bottom: 16px;
}

.search-input {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px 8px 32px;
    color: var(--text);
    font-family: 'Geist Mono', monospace;
    font-size: 12px;
    width: 240px;
}
.search-input:focus { border-color: var(--accent); outline: none; }

/* ── Toggle / Checkbox ── */
.toggle {
    position: relative;
    width: 36px;
    height: 20px;
    display: inline-block;
}
.toggle input { display: none; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text);
    top: 2px;
    left: 2px;
    transition: transform 0.15s ease;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── KV Detail Rows ── */
.detail-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.kv-row {
    display: flex;
    align-items: flex-start;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.kv-row:last-child { border-bottom: none; }

.kv-key {
    width: 160px;
    flex-shrink: 0;
    color: var(--muted);
    font-family: 'Geist Mono', monospace;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.05em;
    padding-top: 1px;
}

.kv-val {
    flex: 1;
    color: var(--text);
    font-family: 'Geist Mono', monospace;
    word-break: break-all;
}

/* ── Modals ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.70);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 480px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}
.modal-close:hover { color: var(--text); }

/* ── Toasts ── */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 12px;
    color: var(--text);
    min-width: 280px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toast-in 0.2s ease;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info    { border-left: 3px solid var(--info); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Section Labels ── */
.section-label {
    font-family: 'Geist Mono', monospace;
    font-size: 11px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 12px;
}

/* ── Hero ── */
.hero {
    padding: 80px 0 60px;
    text-align: left;
    max-width: 1200px;
    margin: 0 auto;
}

.hero-headline {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 56px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: 2px;
    margin-bottom: 20px;
}

.hero-sub {
    font-family: 'Geist Mono', monospace;
    font-size: 14px;
    color: var(--muted);
    line-height: 1.8;
    max-width: 640px;
    margin-bottom: 32px;
}

.hero-cta-group {
    display: flex;
    gap: 12px;
    margin-bottom: 40px;
}

/* ── Stats Strip ── */
.stats-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.stats-strip-item {
    background: var(--panel);
    padding: 20px;
    text-align: center;
}

.stats-strip-number {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
}

.stats-strip-label {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 4px;
}

/* ── Visitor Routing Cards ── */
.route-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.route-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    border-left: 3px solid transparent;
    transition: border-left-color 0.15s ease;
}

.route-card:hover {
    border-left-color: var(--accent);
}

.route-card-label {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.route-card-line {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 16px;
    line-height: 1.6;
}

.route-card-cta {
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
    text-decoration: none;
}

/* ── Section Containers ── */
.section {
    padding: 60px 28px;
    max-width: 1200px;
    margin: 0 auto;
}

.section + .section {
    border-top: 1px solid var(--border);
}

.section-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.section-subtitle {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 32px;
    line-height: 1.6;
    max-width: 640px;
}

/* ── Screenshots ── */
.screenshot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
    margin: 32px 0;
}

.screenshot-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.screenshot-img {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, rgba(0,212,170,0.1), rgba(245,158,11,0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--border);
}

.screenshot-caption {
    padding: 12px 16px;
    font-size: 12px;
    color: var(--muted);
}

/* ── Feature List ── */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.feature-item {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.feature-icon {
    font-size: 24px;
    margin-bottom: 12px;
}

.feature-name {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.feature-desc {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
}

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
}

.pagination-btn {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font-family: 'Geist Mono', monospace;
    font-size: 11px;
    cursor: pointer;
}
.pagination-btn:hover { border-color: var(--accent); color: var(--text); }
.pagination-btn.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.pagination-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Progress Bar ── */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}
.progress-fill.teal  { background: var(--accent); }
.progress-fill.amber { background: var(--amber); }
.progress-fill.red   { background: var(--danger); }

/* ── Tabs ── */
.tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    transition: all 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .page-body { padding: 16px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .route-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-strip { grid-template-columns: repeat(2, 1fr); }
    .hero-headline { font-size: 36px; }
    .screenshot-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .route-grid { grid-template-columns: 1fr; }
    .stats-strip { grid-template-columns: 1fr; }
    .hero-headline { font-size: 28px; }
    .data-grid { font-size: 11px; }
    .data-grid th, .data-grid td { padding: 8px 6px; }
}

/* ── Slide-Out Panel ── */
.slideout-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.50);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.slideout-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.slideout-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 480px;
    max-width: 90vw;
    background: var(--panel);
    border-left: 1px solid var(--border);
    z-index: 901;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.2s ease;
}
.slideout-panel.left {
    left: 0;
    right: auto;
    border-left: none;
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
}
.slideout-panel.right {
    right: 0;
    left: auto;
}
.slideout-panel.slide-in.right {
    transform: translateX(0);
}
.slideout-panel.slide-in.left {
    transform: translateX(0);
}

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

.slideout-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.slideout-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}
.slideout-close:hover { color: var(--text); }

.slideout-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.slideout-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* ── Utility ── */
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-32 { margin-bottom: 32px; }
.mt-20 { margin-top: 20px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-amber { color: var(--amber); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
