/* SD Apps - Clean Dark UI Stylesheet */
:root {
    --bg: #0b0f19;
    --surface: #111827;
    --surface-2: #182234;
    --border: #1f2937;
    --border-hover: #374151;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --radius: 14px;
    --radius-sm: 9px;
}

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

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

a { color: inherit; text-decoration: none; }

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header / Navbar */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(11, 15, 25, 0.88);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 68px;
    flex-wrap: wrap;
    padding: 10px 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.brand img {
    height: 38px;
    max-width: 160px;
    object-fit: contain;
    border-radius: 8px;
}

.brand-badge {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
}

.search-box {
    flex: 1;
    max-width: 420px;
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 6px 4px 16px;
    transition: border-color 0.2s;
}

.search-box:focus-within { border-color: var(--primary); }

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.92rem;
    outline: none;
    padding: 6px 0;
}

.search-box button {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 7px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.search-box button:hover { background: var(--primary-hover); }

/* Hero */
.hero {
    padding: 36px 0 22px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.hero h1 { font-size: 1.85rem; font-weight: 800; letter-spacing: -0.03em; }
.hero p { color: var(--text-muted); margin-top: 4px; font-size: 0.96rem; }

/* Categories */
.categories {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 18px;
    scrollbar-width: none;
}
.categories::-webkit-scrollbar { display: none; }

.cat-pill {
    padding: 7px 16px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
}

.cat-pill:hover, .cat-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* App Grid */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 18px;
    padding-bottom: 48px;
}

.app-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: transform 0.18s ease, border-color 0.18s ease;
}

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

.app-card-top {
    display: flex;
    gap: 14px;
    align-items: center;
}

.app-icon {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.app-icon-lg {
    width: 96px;
    height: 96px;
    border-radius: 20px;
}

.app-meta-title h3 {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
}

.app-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.badge {
    font-size: 0.74rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-blue { color: #60a5fa; border-color: rgba(59, 130, 246, 0.3); background: rgba(59, 130, 246, 0.1); }
.badge-green { color: #34d399; border-color: rgba(16, 185, 129, 0.3); background: rgba(16, 185, 129, 0.1); }

.app-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 10px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.app-actions {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-outline { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--border-hover); background: #1e293b; }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 0.98rem; }
.btn-block { width: 100%; }

/* App Detail Page */
.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin: 28px 0;
}

.detail-header {
    display: flex;
    gap: 22px;
    align-items: center;
    flex-wrap: wrap;
}

.detail-info { flex: 1; min-width: 240px; }
.detail-info h1 { font-size: 1.75rem; font-weight: 800; }

.detail-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin: 22px 0;
}

.stat-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
}

.stat-box .label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-box .value { font-size: 1.15rem; font-weight: 700; margin-top: 4px; color: var(--text); }

/* Screenshots Gallery */
.screenshots-section { margin-top: 28px; }
.screenshots-section h2 { font-size: 1.15rem; margin-bottom: 14px; }

.screenshots-grid {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.screenshot-thumb {
    height: 240px;
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    object-fit: cover;
    transition: transform 0.2s;
}
.screenshot-thumb:hover { transform: scale(1.02); border-color: var(--primary); }

.description-box {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: #cbd5e1;
    white-space: pre-line;
    font-size: 0.96rem;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 95%; max-height: 90vh; border-radius: 12px; }
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 26px;
    font-size: 2rem;
    color: #fff;
    cursor: pointer;
    background: none;
    border: none;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #10b981;
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(14px);
    transition: all 0.25s ease;
    pointer-events: none;
    z-index: 999;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Forms & Admin */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    margin: 24px 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.86rem;
    font-weight: 600;
    color: #cbd5e1;
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.93rem;
    outline: none;
    transition: border-color 0.2s;
}
.form-control:focus { border-color: var(--primary); }
textarea.form-control { min-height: 120px; resize: vertical; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 0.9rem;
    font-weight: 500;
}
.alert-success { background: rgba(16, 185, 129, 0.14); border: 1px solid rgba(16, 185, 129, 0.35); color: #34d399; }
.alert-danger { background: rgba(239, 68, 68, 0.14); border: 1px solid rgba(239, 68, 68, 0.35); color: #f87171; }

/* Admin Table */
.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 13px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

.admin-nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin: 20px 0 40px;
}

footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

@media (max-width: 640px) {
    .hero h1 { font-size: 1.45rem; }
    .detail-card { padding: 18px; }
    .search-box { max-width: 100%; order: 3; width: 100%; }
}
