/* CreatorSync Dashboard — Dark Theme */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2128;
    --bg-hover: #21262d;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-green: #3fb950;
    --accent-blue: #58a6ff;
    --accent-orange: #d29922;
    --accent-purple: #bc8cff;
    --accent-red: #f85149;
    --bar-fill: #58a6ff;
    --bar-bg: #21262d;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
}

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

.sidebar-header h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.version {
    font-size: 11px;
    color: var(--text-muted);
}

.nav-links {
    list-style: none;
    padding: 8px 0;
    flex: 1;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}

.nav-links li a:hover:not(.disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-links li a.active {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-left: 2px solid var(--accent-blue);
}

.nav-links li a.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--border);
    color: var(--text-muted);
    margin-left: auto;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot.green { background: var(--accent-green); }
.dot.red { background: var(--accent-red); }

/* Main content */
.content {
    flex: 1;
    margin-left: 220px;
    padding: 24px 32px;
    max-width: 1200px;
}

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

.page-header h2 {
    font-size: 22px;
    font-weight: 600;
}

/* Buttons */
.btn {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, color 0.15s;
}

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

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.card h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

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

.card-header h3 {
    margin-bottom: 0;
}

/* Disk bar */
.disk-card {
    margin-bottom: 20px;
}

.disk-bar-container {
    max-width: 600px;
}

.disk-bar {
    height: 24px;
    background: var(--bar-bg);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.disk-bar-fill {
    height: 100%;
    background: var(--bar-fill);
    border-radius: 6px;
    transition: width 0.5s ease;
}

/* Color thresholds */
.disk-bar-fill[style*="width: 8"],
.disk-bar-fill[style*="width: 9"] {
    background: var(--accent-orange);
}

.disk-labels {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
}

.disk-total {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Location cards */
.location-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.location-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: border-color 0.15s;
}

.location-card:hover {
    border-color: var(--text-muted);
}

.location-card.green { border-left: 3px solid var(--accent-green); }
.location-card.blue { border-left: 3px solid var(--accent-blue); }
.location-card.orange { border-left: 3px solid var(--accent-orange); }
.location-card.purple { border-left: 3px solid var(--accent-purple); }

.card-icon {
    font-size: 24px;
    line-height: 1;
}

.card-body h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.card-stat.primary {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.card-stat.secondary {
    font-size: 13px;
    color: var(--text-muted);
}

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

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

.data-table td {
    padding: 10px 12px;
}

.data-table .rank {
    color: var(--text-muted);
    width: 40px;
}

.data-table .creator-name {
    font-weight: 500;
}

.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Location badges */
.location-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.location-badge.vl {
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent-green);
}

.location-badge.mega {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent-blue);
}

.location-badge.other {
    background: rgba(139, 148, 158, 0.15);
    color: var(--text-secondary);
}

/* htmx indicators */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-indicator.htmx-request {
    display: inline-block;
}

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

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

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.breadcrumb-link {
    color: var(--accent-blue);
    text-decoration: none;
}

.breadcrumb-link:hover {
    text-decoration: underline;
}

.breadcrumb-sep {
    color: var(--text-muted);
    margin: 0 2px;
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 600;
}

/* File Browser */
.browse-parent {
    margin-bottom: 4px;
}

.browse-up-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.browse-up-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.browse-table {
    margin-top: 8px;
}

.browse-icon {
    font-size: 14px;
    width: 18px;
    display: inline-block;
    text-align: center;
}

.browse-name a {
    color: var(--accent-blue);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.browse-name a:hover {
    text-decoration: underline;
}

.browse-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
}

.browse-modified {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

.type-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 500;
}

.type-badge.dir {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent-blue);
}

.type-badge.file {
    background: rgba(139, 148, 158, 0.15);
    color: var(--text-secondary);
}

.type-badge.link {
    background: rgba(188, 140, 255, 0.15);
    color: var(--accent-purple);
}

.empty-dir {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.empty-dir p {
    font-size: 14px;
}

/* Error banner */
.error-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    border-radius: 8px;
    color: var(--accent-red);
    font-size: 13px;
    margin-bottom: 16px;
}

.error-icon {
    font-size: 16px;
}

/* ===== Magnet Link Ingest ===== */

.magnet-form-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.magnet-form-card h3 {
    margin: 0 0 16px 0;
    font-size: 15px;
    color: var(--text-primary);
}

.magnet-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.magnet-input {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    align-self: flex-start;
}

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

.btn-primary:hover {
    background: #2f81f7;
}

/* Magnet Jobs Section */
.magnet-jobs-section {
    margin-top: 8px;
}

.magnet-jobs-section h3 {
    font-size: 15px;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.magnet-table .job-id {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: var(--accent-blue);
}

.magnet-table .job-magnet {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.magnet-table .job-submitted {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.submitted {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent-blue);
}

.status-badge.downloading {
    background: rgba(210, 153, 34, 0.15);
    color: var(--accent-yellow);
}

.status-badge.complete {
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent-green);
}

.status-badge.error {
    background: rgba(248, 81, 73, 0.15);
    color: var(--accent-red);
}

.job-error {
    font-size: 11px;
    color: var(--accent-red);
    margin-top: 4px;
    max-width: 300px;
    word-wrap: break-word;
}

.empty-jobs {
    text-align: center;
    padding: 32px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ===== Configuration Management ===== */

.config-category {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.config-category-title {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.config-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.config-item-info {
    flex: 1;
    min-width: 0;
}

.config-item-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.config-item-desc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.config-item-value-area {
    flex-shrink: 0;
    margin-left: 24px;
}

.config-item-editable,
.config-item-readonly {
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-value {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.08);
    padding: 4px 10px;
    border-radius: 4px;
}

.config-badge.readonly {
    font-size: 10px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.config-edit-form {
    display: flex;
    align-items: center;
    gap: 6px;
}

.config-edit-input {
    width: 220px;
    padding: 6px 10px;
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.config-item.config-error .config-value {
    color: var(--accent-red);
    background: rgba(248, 81, 73, 0.08);
}

/* Small buttons */
.btn-sm {
    padding: 4px 10px;
    font-size: 11px;
}

.btn-edit {
    background: rgba(88, 166, 255, 0.12);
    color: var(--accent-blue);
    border: 1px solid rgba(88, 166, 255, 0.2);
}

.btn-edit:hover {
    background: rgba(88, 166, 255, 0.2);
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ===== Login Page ===== */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px 40px;
    width: 360px;
    max-width: 90vw;
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-header h1 {
    font-size: 22px;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.login-header .version {
    font-size: 11px;
    color: var(--text-secondary);
}

.login-card .form-group {
    margin-bottom: 16px;
}

.login-card label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-card .form-input {
    width: 100%;
    box-sizing: border-box;
}

.login-btn {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    margin-top: 8px;
}

.login-card .error-banner {
    margin-bottom: 16px;
}

/* Logout link */
.logout-link {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 4px 16px;
    margin-bottom: 4px;
}

.logout-link:hover {
    color: var(--accent-red);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    .sidebar-header h1,
    .sidebar-header .version,
    .nav-links li a span:not(.nav-icon),
    .sidebar-footer span:not(.dot),
    .badge {
        display: none;
    }
    .nav-links li a {
        justify-content: center;
        padding: 12px;
    }
    .content {
        margin-left: 60px;
        padding: 16px;
    }
    .location-cards {
        grid-template-columns: 1fr 1fr;
    }
}
