/* ============================================
   CASTA — Rust Map Hosting
   Dark Minimalist Industrial Design
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Manrope:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #161616;
    --bg-card-hover: #1a1a1a;
    --bg-input: #0e0e0e;
    --border: #222222;
    --border-hover: #333333;
    --border-focus: #cd412b;
    --text-primary: #e8e4e0;
    --text-secondary: #7a7672;
    --text-muted: #4a4744;
    --accent: #cd412b;
    --accent-hover: #e04a33;
    --accent-dim: rgba(205, 65, 43, 0.1);
    --accent-glow: rgba(205, 65, 43, 0.15);
    --green: #3d9970;
    --green-dim: rgba(61, 153, 112, 0.1);
    --yellow: #c49a2a;
    --yellow-dim: rgba(196, 154, 42, 0.1);
    --danger: #c0392b;
    --danger-dim: rgba(192, 57, 43, 0.1);
    --font-display: 'Space Mono', monospace;
    --font-body: 'Manrope', sans-serif;
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

/* Subtle noise overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

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

/* ===== LAYOUT ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 32px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 0 28px 32px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.sidebar-brand h1 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 4px;
    text-transform: uppercase;
}

.sidebar-brand span {
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
    display: block;
    margin-top: 4px;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.87rem;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 4px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--accent-dim);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-left: 2px solid var(--accent);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav-item.active svg { opacity: 1; }

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

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent-dim);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 700;
}

.user-info .user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-info .user-role {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 40px 48px;
    min-height: 100vh;
}

/* ===== PAGE HEADER ===== */
.page-header {
    margin-bottom: 36px;
}

.page-header h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.87rem;
    margin-top: 6px;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    transition: border-color var(--transition);
}

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

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

.card-title {
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
    margin-bottom: 10px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value .stat-unit {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-left: 4px;
}

/* ===== STORAGE BAR ===== */
.storage-bar-wrapper {
    margin-top: 16px;
}

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

.storage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.storage-bar-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15));
    border-radius: 0 3px 3px 0;
}

.storage-bar-fill.warning { background: linear-gradient(90deg, var(--yellow), #d4a82e); }
.storage-bar-fill.danger { background: linear-gradient(90deg, var(--danger), #d44837); }

.storage-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* ===== UPLOAD ZONE ===== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 32px;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
    position: relative;
    background: var(--bg-card);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.upload-zone.dragover {
    box-shadow: 0 0 30px var(--accent-glow);
}

.upload-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    color: var(--text-muted);
    transition: color var(--transition);
}

.upload-zone:hover .upload-icon { color: var(--accent); }

.upload-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Upload progress */
.upload-progress {
    display: none;
    margin-top: 20px;
}

.upload-progress.active { display: block; }

.progress-bar {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* ===== MAP LIST TABLE ===== */
.maps-table {
    width: 100%;
    border-collapse: collapse;
}

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

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

.maps-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.015);
}

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

.maps-table td {
    padding: 16px;
    font-size: 0.87rem;
    vertical-align: middle;
}

.map-name {
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.map-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-dim);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.map-icon svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.map-size {
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.map-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.map-downloads {
    font-family: var(--font-display);
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* Link field */
.link-field {
    display: flex;
    align-items: center;
    gap: 6px;
}

.link-input {
    font-family: var(--font-display);
    font-size: 0.7rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 8px;
    color: var(--text-secondary);
    width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-copy {
    padding: 6px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
}

.btn-copy:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-copy.copied {
    border-color: var(--green);
    color: var(--green);
}

.btn-copy svg { width: 14px; height: 14px; }

/* Map actions */
.map-actions {
    display: flex;
    gap: 6px;
}

.btn-action {
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.btn-action.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-dim);
}

.btn-action svg { width: 15px; height: 15px; }

/* ===== BUTTONS ===== */
.btn {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.3px;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(205, 65, 43, 0.25);
}

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

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

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.78rem;
}

.btn svg { width: 16px; height: 16px; }

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: all var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ===== ALERTS ===== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 20px;
    border: 1px solid;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: var(--green-dim);
    border-color: rgba(61, 153, 112, 0.3);
    color: var(--green);
}

.alert-error {
    background: var(--danger-dim);
    border-color: rgba(192, 57, 43, 0.3);
    color: var(--danger);
}

.alert-warning {
    background: var(--yellow-dim);
    border-color: rgba(196, 154, 42, 0.3);
    color: var(--yellow);
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ===== AUTH PAGES ===== */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    position: relative;
    z-index: 1;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 36px;
}

.auth-brand h1 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.auth-brand p {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.auth-divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

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

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.empty-state .empty-hint {
    font-size: 0.78rem;
}

/* ===== MODAL / CONFIRM ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 420px;
    width: 90%;
}

.modal h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    margin-bottom: 12px;
}

.modal p {
    font-size: 0.87rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ===== SETTINGS LAYOUT ===== */
.settings-grid {
    display: grid;
    gap: 24px;
    max-width: 600px;
}

.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
}

.settings-section h3 {
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    font-size: 0.85rem;
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    max-width: 360px;
}

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

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    .main-content {
        margin-left: 0;
        padding: 24px 16px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .link-input {
        width: 140px;
    }
    .maps-table {
        display: block;
        overflow-x: auto;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeIn 0.4s ease both;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
