/* === AppHosting Dashboard === */

:root {
    --sidebar-bg: #111827;
    --sidebar-text: #9ca3af;
    --sidebar-text-hover: #f3f4f6;
    --sidebar-active-bg: rgba(255, 255, 255, 0.08);
    --content-bg: #f9fafb;
    --card-bg: #fff;
    --text: #111827;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --green: #059669;
    --red: #dc2626;
    --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);
    --radius: 8px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--content-bg);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

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

/* ======================== LAYOUT ======================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

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

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand a {
    color: #fff;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.sidebar-brand a:hover { color: #fff; }

.sidebar-nav {
    padding: 0.75rem 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-section-label {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.3);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--sidebar-text);
    transition: all 0.15s ease;
    font-weight: 400;
}

.nav-item:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-active-bg);
}

.nav-item.active {
    color: #fff;
    background: var(--sidebar-active-bg);
    font-weight: 500;
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    opacity: 0.5;
    flex-shrink: 0;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
    opacity: 0.8;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer a {
    color: var(--sidebar-text);
    font-size: 0.8125rem;
}

.sidebar-footer a:hover {
    color: var(--sidebar-text-hover);
}

/* Main content */
.main-content {
    margin-left: 260px;
    flex: 1;
    min-height: 100vh;
    background: var(--content-bg);
}

.content-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.content-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.content-header .subtitle {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0.125rem 0 0;
}

.content-body {
    padding: 1.5rem 2rem 2rem;
}

/* ======================== CARDS ======================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 1rem 1.25rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.875rem;
}

.card-body { padding: 1.25rem; }
.card-body.p-0 { padding: 0; }

/* ======================== STAT CARDS ======================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

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

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text);
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 0.375rem;
}

/* ======================== TABLES ======================== */
.table-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.table-card-header h2 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead th {
    padding: 0.75rem 1.25rem;
    text-align: left;
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: #fafafa;
}

.data-table tbody td {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

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

.data-table tbody tr:hover {
    background: #fafbfc;
}

.data-table .text-end { text-align: right; }

/* ======================== BADGES ======================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2em 0.6em;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
}

.badge-proxy { background: #dbeafe; color: #1e40af; }
.badge-static { background: #dcfce7; color: #166534; }

/* ======================== STATUS ======================== */
.status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
}

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

.status-active .status-dot { background: var(--green); }
.status-active { color: var(--green); }
.status-disabled .status-dot { background: #d1d5db; }
.status-disabled { color: var(--text-secondary); }

/* ======================== BUTTONS ======================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.25;
}

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

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

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

.btn-secondary:hover {
    background: #f3f4f6;
    color: var(--text);
}

.btn-danger {
    background: var(--card-bg);
    border-color: var(--border);
    color: var(--red);
}

.btn-danger:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--red);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-group {
    display: inline-flex;
    gap: 0.5rem;
}

/* ======================== FORMS ======================== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 0.375rem;
}

.form-hint {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.form-control,
.form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text);
    background: var(--card-bg);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
}

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

.form-control::placeholder { color: #9ca3af; }

/* ======================== PAGE HEADERS ======================== */
.page-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ======================== DETAIL VIEW ======================== */
.detail-grid {
    display: grid;
    gap: 0;
}

.detail-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    border-bottom: 1px solid #f3f4f6;
    padding: 0.75rem 0;
}

.detail-row:last-child { border-bottom: none; }

.detail-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-value {
    font-size: 0.875rem;
    color: var(--text);
}

.detail-value code {
    background: #f3f4f6;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.8125rem;
    color: var(--text);
}

/* ======================== EMPTY STATE ======================== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.375rem;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0 0 1.25rem;
}

/* ======================== AUTH PAGES ======================== */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--content-bg);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 0 1rem;
}

.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-brand span {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.auth-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    margin: 0 0 0.25rem;
}

.auth-card .auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0 0 1.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.auth-footer a { font-weight: 500; }

/* ======================== ALERTS ======================== */
.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* ======================== BREADCRUMB ======================== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0;
    padding: 0;
    list-style: none;
}

.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .separator { color: #d1d5db; }

/* ======================== SPINNER ======================== */
.spinner {
    display: flex;
    justify-content: center;
    padding: 3rem 0;
}

.spinner::after {
    content: "";
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ======================== MISC ======================== */
.form-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.text-muted { color: var(--text-secondary); }

code {
    background: #f3f4f6;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.8125rem;
}

/* ======================== FILE BROWSER ======================== */
.file-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.file-new-folder {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.file-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    text-decoration: none;
}

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

.file-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.file-upload-status {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #1e40af;
}

/* ======================== MODAL ======================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-dialog {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 400px;
}

.modal-header {
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.9375rem;
    border-bottom: 1px solid var(--border);
}

.modal-body { padding: 1.25rem; }

.modal-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}
