/* ===================================================================
   Portfolio — Spotify-inspired Black & Green Theme
   =================================================================== */

/* --- CSS Variables / Theme Tokens --- */
:root {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-card: #181818;
    --bg-card-hover: #282828;
    --bg-elevated: #242424;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #727272;
    --accent: #1db954;
    --accent-hover: #1ed760;
    --accent-dark: #169c46;
    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --border: #333333;
    --border-light: #404040;
    --shadow: rgba(0, 0, 0, 0.3);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
             Oxygen, Ubuntu, Cantarell, sans-serif;
    --max-width: 1400px;
    --nav-height: 56px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* --- Navbar --- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
}

.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent) !important;
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-links a {
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-links a:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

/* --- Main Content --- */
.main-content {
    padding-top: var(--nav-height);
    min-height: 100vh;
}

/* --- Hero Section --- */
.hero {
    text-align: center;
    padding: 48px 24px 32px;
    max-width: var(--max-width);
    margin: 0 auto;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ===================================================================
   Bento Grid
   =================================================================== */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    padding: 0 24px 48px;
    max-width: var(--max-width);
    margin: 0 auto;
    grid-auto-flow: dense;
}

.bento-item {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--text-primary);
    min-height: 120px;
}

.bento-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(29, 185, 84, 0.15);
}

.bento-image {
    width: 100%;
    overflow: hidden;
    flex-shrink: 0;
}

.bento-image img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.bento-item:hover .bento-image img {
    transform: scale(1.05);
}

.bento-content {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bento-title {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
}

/* Child thumbnails inside parent bento box */
.bento-children {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.bento-child-thumb {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 3px 8px 3px 3px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.bento-child-thumb img {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    object-fit: cover;
}

.bento-child-more {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 3px 8px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
}

.bento-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 64px 24px;
    color: var(--text-secondary);
}

/* --- Responsive Bento Grid --- */
@media (max-width: 1024px) {
    .bento-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 0 16px 32px;
    }
    .hero h1 { font-size: 1.8rem; }
}

@media (max-width: 480px) {
    .bento-grid {
        grid-template-columns: 1fr;
    }
}

/* ===================================================================
   Project Detail Page
   =================================================================== */
.project-detail {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 24px;
}

.breadcrumb {
    margin-bottom: 24px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-secondary);
}

.breadcrumb a:hover {
    color: var(--accent);
}

.breadcrumb-sep {
    margin: 0 8px;
    color: var(--text-muted);
}

.project-header {
    margin-bottom: 24px;
}

.project-hero-image {
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    overflow: hidden;
    max-height: 400px;
}

.project-hero-image img {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: cover;
}

.project-header h1 {
    font-size: 2rem;
    font-weight: 700;
}

.project-description {
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 1rem;
}

.project-description img {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin: 16px 0;
}

.project-custom-fields {
    margin-top: 24px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.custom-field {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.custom-field:last-child {
    border-bottom: none;
}

.custom-field strong {
    color: var(--accent);
    margin-right: 8px;
}

/* Children Section */
.children-section {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px 48px;
}

.children-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* ===================================================================
   Auth Pages
   =================================================================== */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - var(--nav-height));
    padding: 24px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    text-align: center;
}

.auth-back {
    margin-top: 16px;
    text-align: center;
    font-size: 0.9rem;
}

/* ===================================================================
   Admin Pages
   =================================================================== */
.admin-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 24px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.admin-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

.admin-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

/* Sortable List */
.sortable-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sortable-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    transition: all 0.2s ease;
}

.sortable-item:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
}

.sortable-item.sortable-chosen {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(29, 185, 84, 0.3);
}

.sortable-handle {
    cursor: grab;
    font-size: 1.3rem;
    color: var(--text-muted);
    user-select: none;
    padding: 4px;
}

.sortable-handle:active {
    cursor: grabbing;
}

.sortable-content {
    flex: 1;
    min-width: 0;
}

.sortable-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary) !important;
}

.sortable-title:hover {
    color: var(--accent) !important;
}

.sortable-meta {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    flex-wrap: wrap;
}

.sortable-meta strong {
    color: var(--text-secondary);
}

.sortable-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 2px dashed var(--border);
}

/* ===================================================================
   Forms
   =================================================================== */
.project-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: var(--font);
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.15);
}

.form-group input[type="file"] {
    background: var(--bg-elevated);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
}

.form-group input[type="file"]:hover {
    border-color: var(--accent);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-hint code {
    background: var(--bg-elevated);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.current-image {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
}

.current-image-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.code-textarea {
    font-family: "Consolas", "Courier New", monospace !important;
    font-size: 0.85rem !important;
}

.form-details {
    cursor: pointer;
}

.form-details summary {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 8px 0;
}

.form-details[open] summary {
    margin-bottom: 12px;
}

/* --- Quill.js Overrides --- */
.ql-toolbar {
    background: var(--bg-elevated);
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-family: var(--font) !important;
}

.ql-container {
    background: var(--bg-primary);
    border: 1px solid var(--border) !important;
    border-top: none !important;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font) !important;
    color: var(--text-primary);
}

.ql-editor {
    min-height: 280px;
    color: var(--text-primary);
}

.ql-editor.ql-blank::before {
    color: var(--text-muted) !important;
    font-style: normal !important;
}

.ql-snow .ql-stroke {
    stroke: var(--text-secondary) !important;
}

.ql-snow .ql-fill {
    fill: var(--text-secondary) !important;
}

.ql-snow .ql-picker {
    color: var(--text-secondary) !important;
}

.ql-snow .ql-active .ql-stroke {
    stroke: var(--accent) !important;
}

.ql-snow .ql-active .ql-fill {
    fill: var(--accent) !important;
}

.ql-snow .ql-picker-options {
    background: var(--bg-elevated) !important;
    border-color: var(--border) !important;
}

.ql-snow .ql-picker-label:hover {
    color: var(--accent) !important;
}

.ql-snow .ql-picker-label:hover .ql-stroke {
    stroke: var(--accent) !important;
}

/* ===================================================================
   Buttons
   =================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #000 !important;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(29, 185, 84, 0.3);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary) !important;
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}

.btn-danger {
    background: var(--danger);
    color: #fff !important;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
}

/* ===================================================================
   Alerts
   =================================================================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.alert-error {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
}

/* ===================================================================
   Utilities
   =================================================================== */
@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .sortable-meta {
        flex-direction: column;
        gap: 4px;
    }
    .sortable-actions {
        flex-direction: column;
    }
    .project-form {
        padding: 20px;
    }
}

/* ===================================================================
   Bento Drag Handle (admin only)
   =================================================================== */
.bento-drag-handle {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    cursor: grab;
    font-size: 1.2rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.6);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    line-height: 1;
    user-select: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.bento-item:hover .bento-drag-handle {
    opacity: 1;
}

.bento-drag-handle:active {
    cursor: grabbing;
}

/* ===================================================================
   Analytics Bar
   =================================================================== */
.analytics-bar {
    display: flex;
    gap: 24px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}

.analytics-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.analytics-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.analytics-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===================================================================
   Project Overview
   =================================================================== */
.project-overview {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 24px;
    padding: 16px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent);
}

/* ===================================================================
   Admin Header Actions
   =================================================================== */
.admin-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
