/* ============================================
   Pirelli Creative Gallery – Light Theme
   ============================================ */

:root {
    --color-bg: #f5f5f5;
    --color-surface: #ffffff;
    --color-surface-hover: #fafafa;
    --color-surface-elevated: #ffffff;
    --color-border: #e2e2e2;
    --color-border-subtle: #ececec;
    --color-text: #1a1a1a;
    --color-text-secondary: #4a4a4a;
    --color-text-muted: #636363;
    --color-accent: #cc0000;
    --color-accent-hover: #a30000;
    --color-accent-light: rgba(204, 0, 0, 0.06);
    --color-green: #15803d;
    --color-green-light: rgba(21, 128, 61, 0.08);
    --color-blue: #2563eb;
    --color-blue-light: rgba(37, 99, 235, 0.08);
    --color-red: #dc2626;
    --color-red-hover: #b91c1c;
    --color-yellow: #fdd000;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.04);
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

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

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

/* ── Login ──────────────────────────────── */

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

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 0 24px;
}

.login-brand {
    text-align: center;
    margin-bottom: 48px;
}

.pirelli-logo {
    height: 28px;
    width: auto;
    display: block;
    margin: 0 auto 14px;
}

.login-title {
    font-size: 14px;
    font-weight: 400;
    color: var(--color-text-secondary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-form-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
}

.login-error {
    background: rgba(220, 38, 38, 0.06);
    border: 1px solid rgba(220, 38, 38, 0.15);
    color: var(--color-red);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
}

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

/* ── Forms ──────────────────────────────── */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-family: var(--font);
    font-size: 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.08);
}

input::placeholder, textarea::placeholder {
    color: var(--color-text-muted);
}

input[type="file"] {
    font-family: var(--font);
    font-size: 13px;
    color: var(--color-text-secondary);
}

input[type="file"]::file-selector-button {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    padding: 8px 16px;
    font-family: var(--font);
    font-size: 13px;
    cursor: pointer;
    margin-right: 12px;
    transition: background var(--transition);
}

input[type="file"]::file-selector-button:hover {
    background: var(--color-border-subtle);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-row-inline {
    display: flex;
    gap: 12px;
}

.form-row-inline input {
    flex: 1;
}

/* Checkboxes */
.checkbox-group, .radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.checkbox-group-vertical, .radio-group-vertical {
    flex-direction: column;
    gap: 10px;
}

.checkbox-label, .radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text);
    user-select: none;
}

.checkbox-label input, .radio-label input {
    display: none;
}

.checkbox-box {
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--color-border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    background: var(--color-surface);
}

.checkbox-label input:checked + .checkbox-box,
.radio-label input:checked + .checkbox-box {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.checkbox-label input:checked + .checkbox-box::after,
.radio-label input:checked + .checkbox-box::after {
    content: '';
    width: 10px;
    height: 6px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
}

/* Radio dots */
.radio-dot {
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--color-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    background: var(--color-surface);
}

.radio-label input:checked + .radio-dot {
    border-color: var(--color-accent);
}

.radio-label input:checked + .radio-dot::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-accent);
}

/* Brand Selector */
.brand-selector {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    max-height: 280px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.brand-search {
    border: none !important;
    border-bottom: 1px solid var(--color-border) !important;
    border-radius: 0 !important;
    padding: 10px 14px !important;
}

.brand-list {
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-item {
    padding: 6px 8px;
    border-radius: 4px;
    transition: background var(--transition);
}

.brand-item:hover {
    background: var(--color-bg);
}

/* ── Buttons ──────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}

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

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

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

.btn-ghost:hover {
    background: var(--color-bg);
    color: var(--color-text);
    border-color: var(--color-text-muted);
}

.btn-danger {
    background: transparent;
    border: 1px solid rgba(220, 38, 38, 0.25);
    color: var(--color-red);
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.05);
}

.btn-full { width: 100%; justify-content: center; }

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* ── Gallery Header ───────────────────── */

.gallery-header, .admin-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--color-border);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.header-brand .pirelli-logo {
    height: 22px;
    width: auto;
}

.header-title {
    font-size: 13px;
    font-weight: 400;
    color: var(--color-text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-left: 1px solid var(--color-border);
    padding-left: 16px;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.motif-count {
    font-size: 13px;
    color: var(--color-text-muted);
}

.btn-logout {
    color: var(--color-text-muted);
    transition: color var(--transition);
    text-decoration: none;
}

.btn-logout:hover {
    color: var(--color-text);
}

/* ── Filter Bar ───────────────────────── */

.gallery-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.filter-bar {
    margin-bottom: 32px;
}

.filter-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-wrap {
    flex: 1;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 12px 14px 12px 42px !important;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 14px;
    box-shadow: var(--shadow-sm);
}

.btn-filter-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text-secondary);
    font-family: var(--font);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.btn-filter-toggle:hover {
    border-color: var(--color-text-muted);
    color: var(--color-text);
}

.filter-badge {
    background: var(--color-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-panel {
    display: none;
    margin-top: 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    animation: slideDown 0.2s ease;
}

.filter-panel.is-open {
    display: block;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.filter-grid label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.filter-grid select {
    padding: 8px 12px;
    font-size: 13px;
}

.filter-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid var(--color-border-subtle);
}

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

/* ── Gallery Grid ─────────────────────── */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.motif-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-card);
}

.motif-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.motif-card.is-archived {
    opacity: 0.5;
}

.motif-card.is-archived:hover {
    opacity: 0.8;
}

.motif-preview {
    position: relative;
    aspect-ratio: 210 / 297;
    background: var(--color-bg);
    overflow: hidden;
    cursor: pointer;
}

.motif-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.4s ease;
}

.motif-card:hover .motif-preview img {
    transform: scale(1.02);
}

.no-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
}

.archive-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-sm);
}

.motif-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.motif-overlay svg {
    color: white;
}

.motif-card:hover .motif-overlay {
    opacity: 1;
}

.motif-info {
    padding: 16px;
}

.motif-id {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-accent);
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.motif-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 10px;
    color: var(--color-text);
}

.motif-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border-subtle);
}

.tag {
    display: inline-flex;
    padding: 3px 8px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
    letter-spacing: 0.02em;
}

.tag-green {
    background: var(--color-green-light);
    border-color: rgba(21, 128, 61, 0.2);
    color: var(--color-green);
}

.tag-blue {
    background: var(--color-blue-light);
    border-color: rgba(37, 99, 235, 0.15);
    color: var(--color-blue);
}

.tag-neutral {
    background: var(--color-bg);
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

.tag-small {
    padding: 2px 6px;
    font-size: 11px;
}

.motif-brands {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.4;
    margin-bottom: 6px;
}

.motif-variants {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    margin-bottom: 6px;
}

.variants-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 2px;
}

.variant-tag {
    display: inline-flex;
    padding: 2px 7px;
    background: transparent;
    border: 1px dashed var(--color-border);
    border-radius: 3px;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.motif-date {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 8px;
}

.motif-valid-until {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.motif-remarks {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 8px;
    font-style: italic;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Empty State ──────────────────────── */

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

.empty-state svg {
    margin-bottom: 16px;
}

.empty-state p {
    margin-bottom: 16px;
    font-size: 15px;
}

/* ── Lightbox ─────────────────────────── */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(16px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
    cursor: pointer;
}

.lightbox.is-open {
    display: flex;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    z-index: 10;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-content {
    max-width: 90vw;
    max-height: 85vh;
    cursor: default;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.lightbox-info {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

/* ── Admin ────────────────────────────── */

.admin-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.admin-table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    background: var(--color-surface);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.admin-table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--color-border-subtle);
    vertical-align: middle;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: var(--color-surface-hover);
}

.admin-table .row-archived td {
    opacity: 0.45;
}

.cell-preview { width: 60px; }
.cell-id { font-weight: 600; color: var(--color-accent); white-space: nowrap; }
.cell-loc { white-space: nowrap; }
.cell-center { text-align: center; }
.cell-actions { white-space: nowrap; }

.thumb {
    width: 48px;
    height: 68px;
    object-fit: contain;
    border-radius: 4px;
    background: var(--color-bg);
}

.thumb-empty {
    width: 48px;
    height: 68px;
    border-radius: 4px;
    background: var(--color-bg);
    border: 1px dashed var(--color-border);
}

.empty-cell {
    text-align: center;
    color: var(--color-text-muted);
    padding: 40px !important;
}

.status-active {
    color: var(--color-green);
    font-size: 13px;
    font-weight: 500;
}

.status-archived {
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 500;
}

/* ── Edit Form ────────────────────────── */

.edit-container {
    max-width: 740px;
}

.edit-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 32px;
}

.edit-subtitle {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.edit-form {
    margin-bottom: 40px;
}

.current-preview {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--color-bg);
    border-radius: var(--radius);
}

.current-preview img {
    width: 60px;
    height: 85px;
    object-fit: contain;
    border-radius: 4px;
}

.current-preview span {
    font-size: 13px;
    color: var(--color-text-muted);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 24px;
    border-top: 1px solid var(--color-border-subtle);
}

.add-brand-form {
    margin-bottom: 24px;
}

/* ── Alerts ───────────────────────────── */

.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 20px;
}

.alert-success {
    background: var(--color-green-light);
    border: 1px solid rgba(21, 128, 61, 0.2);
    color: var(--color-green);
}

.alert-error {
    background: rgba(220, 38, 38, 0.06);
    border: 1px solid rgba(220, 38, 38, 0.15);
    color: var(--color-red);
}

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

/* ── Responsive ───────────────────────── */

@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .gallery-main, .admin-main {
        padding: 16px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 16px;
    }

    .filter-row {
        flex-direction: column;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .filter-footer {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .lightbox {
        padding: 16px;
    }

    .motif-info {
        padding: 12px;
    }

    .motif-title {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .motif-id { font-size: 11px; }
    .motif-title { font-size: 14px; }
    .motif-meta .tag { font-size: 11px; padding: 2px 6px; }
    .variant-tag { font-size: 11px; }
    .motif-brands { font-size: 12px; }
    .motif-date, .motif-valid-until, .motif-remarks { font-size: 12px; }
}
