/* ===== AO Lego Collections — Playful Flat + Soft Shadows ===== */
:root {
    --red: #E3000B;
    --blue: #006CB7;
    --yellow: #FFD700;
    --green: #00A651;
    --orange: #FF8C00;
    --bg: #FFF8F0;
    --surface: #FFFFFF;
    --text: #2D2D2D;
    --text2: #6B6B6B;
    --border: #F0EBE4;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-hover: 0 8px 24px rgba(0,0,0,0.10);
    --radius: 16px;
    --radius-sm: 10px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== Cards / Panels ===== */
.card-panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* ===== Header ===== */
.header {
    background: var(--red);
    color: #fff;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(227,0,11,0.25);
}
.header h1 { font-size: 1.4rem; font-weight: 700; }
.header h1 span { color: var(--yellow); }
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.header a { color: #fff; text-decoration: none; font-weight: 500; opacity: 0.9; transition: opacity 0.2s; }
.header a:hover { opacity: 1; }
.header-count { font-size: 0.85rem; opacity: 0.8; }
.header-sep { opacity: 0.5; }

/* ===== Stats bar ===== */
.stats {
    display: flex;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    flex-wrap: wrap;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
    text-align: center;
    flex: 1;
    min-width: 100px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.stat-card .num { font-size: 1.5rem; font-weight: 700; }
.stat-card .num.color-green { color: var(--green); }
.stat-card .num.color-orange { color: var(--orange); }
.stat-card .num.color-red { color: var(--red); }
.stat-card .num.color-blue { color: var(--blue); }
.stat-card .label { font-size: 0.75rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== Filters ===== */
.filters {
    padding: 0 1.5rem 1rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}
.search-box {
    flex: 1;
    min-width: 200px;
    padding: 0.7rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color 0.2s;
}
.search-box:focus { border-color: var(--blue); }
.filter-select {
    padding: 0.7rem 2rem 0.7rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}
.filter-select:focus { border-color: var(--blue); }

/* ===== Multi-select dropdown ===== */
.multi-select { position: relative; }
.multi-select-btn { text-align: left; white-space: nowrap; }
.multi-select-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    z-index: 50;
    min-width: 160px;
    padding: 0.4rem 0;
}
.multi-select-dropdown.open { display: block; }
.multi-select-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.1s;
}
.multi-select-item:hover { background: #f5f0ea; }
.multi-select-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--blue);
    cursor: pointer;
}

/* ===== Table ===== */
.table-wrap { padding: 0 1.5rem 2rem; }
.table-container {
    padding: 1.25rem;
}
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
}
thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    background: var(--red);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: sticky;
    top: 56px;
    z-index: 10;
    box-shadow: 0 -4px 0 var(--bg);
}
thead th:not([data-sort]) { cursor: default; }
thead th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
thead th:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
thead th:hover { color: var(--yellow); }
thead th .sort-arrow { margin-left: 4px; font-size: 0.7rem; }
tbody tr {
    background: var(--surface);
    border-radius: var(--radius-sm);
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
tbody tr:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}
tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}
tbody tr td:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
tbody tr td:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.lego-id { color: var(--blue); font-family: monospace; font-size: 1rem; }
.lego-name { font-weight: 600; }
.lego-link a { color: var(--blue); text-decoration: none; font-size: 0.85rem; word-break: break-all; }
.lego-link a:hover { text-decoration: underline; }

.thumb { width: 80px; height: 80px; object-fit: contain; border-radius: 8px; cursor: pointer; background: #f5f0ea; }
.thumb-placeholder { width: 80px; height: 80px; border-radius: 8px; background: #f5f0ea; display: flex; align-items: center; justify-content: center; color: #ccc; font-size: 1.2rem; }

/* ===== Status badges ===== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ===== Type pills ===== */
.type-pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* ===== Card layout (mobile) ===== */
.cards { display: none; padding: 0 1rem 2rem; }
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.card-img { flex-shrink: 0; }
.card-body { flex: 1; min-width: 0; }
.card-body .lego-id { font-size: 0.85rem; }
.card-body .lego-name { font-size: 1rem; display: block; margin: 0.25rem 0; }
.card-body .meta { font-size: 0.8rem; color: var(--text2); display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.4rem; }

/* ===== Image hover preview ===== */
.thumb-wrap { position: relative; display: inline-block; }
.thumb-preview {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    max-width: 1024px;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    border: 2px solid var(--border);
    background: var(--surface);
    z-index: 999;
    pointer-events: none;
}

/* ===== Lightbox ===== */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 999;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.lightbox.active { display: flex; }
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,0.5); }

/* ===== Login ===== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.login-box {
    width: 100%;
    max-width: 380px;
    padding: 2.5rem 2rem;
    text-align: center;
}
.login-box h2 { margin-bottom: 1.5rem; color: var(--red); font-size: 1.5rem; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; text-align: left; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--text2); }
.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--blue); }
.password-wrap { position: relative; }
.password-wrap .form-input { padding-right: 3rem; }
.pw-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.pw-toggle:hover { opacity: 1; }
.form-select {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236B6B6B'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}
.form-select:focus { border-color: var(--blue); }

.btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--red);
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.btn-blue { background: var(--blue); }
.btn-sm { padding: 0.4rem 1rem; font-size: 0.85rem; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: #FDECEC; color: var(--red); }
.alert-success { background: #E8F8EF; color: var(--green); }

/* ===== Admin panel ===== */
.admin-wrap { max-width: 900px; margin: 2rem auto; padding: 0 1.5rem; }
.admin-section { padding: 1.5rem; margin-bottom: 1.5rem; }
.admin-section h3 { margin-bottom: 1rem; color: var(--red); }
.type-stats { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { margin-top: 1.25rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th, .admin-table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; height: 3rem; }
.admin-table th { color: #fff; background: var(--red); font-size: 0.75rem; text-transform: uppercase; position: sticky; top: 56px; z-index: 10; box-shadow: 0 -4px 0 var(--bg); }
.admin-table td:last-child, .admin-table th:last-child { white-space: nowrap; }
.admin-table td:nth-child(4) { white-space: nowrap; }
.admin-table td:nth-child(5) { white-space: nowrap; text-align: center; }
.admin-table .btn-edit, .admin-table .btn-del { vertical-align: middle; }
.admin-table .del-form { display: inline; }
.quick-status {
    padding: 0.25rem 1.8rem 0.25rem 0.5rem;
    border: none;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: opacity 0.2s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236B6B6B'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    width: auto;
    max-width: 150px;
}
.quick-status:hover { opacity: 0.8; }
.quick-status.saving { opacity: 0.5; }
.quick-status option { background: #fff; color: var(--text); }
.btn-edit, .btn-del {
    padding: 0.35rem 0.75rem;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
}
.btn-edit { background: #E6F2FB; color: var(--blue); }
.btn-del { background: #FDECEC; color: var(--red); }
.btn-edit:hover { background: #D0E6F7; }
.btn-del:hover { background: #FACFCF; }
.del-form { display: inline; }
.img-toggle { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
#imageFileGroup { display: none; }
#resetFilters { white-space: nowrap; padding: 0.7rem 1.25rem; font-size: 0.9rem; }
#emptyTable, #emptyCards { display: none; }
.login-back { margin-top: 1rem; }
.login-back a { color: var(--blue); font-size: 0.85rem; }
.btn-full { width: 100%; }
.half-width { width: 50%; }

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.8rem;
    color: var(--text2);
}
.footer a { color: var(--blue); text-decoration: none; }

/* ===== Empty state ===== */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text2); }
.empty .icon { font-size: 3rem; margin-bottom: 0.5rem; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header { padding: 0.75rem 1rem; }
    .header h1 { font-size: 1.1rem; }
    .stats { padding: 0.75rem 1rem; }
    .filters { padding: 0 1rem 0.75rem; }
    .table-wrap { display: none; }
    .cards { display: block; }
    .form-row { grid-template-columns: 1fr; }
    .admin-wrap { padding: 0 1rem; }
    .admin-table-wrap { overflow-x: auto; }
}

@media (max-width: 480px) {
    .stat-card { min-width: 70px; padding: 0.5rem 0.75rem; }
    .stat-card .num { font-size: 1.2rem; }
}
