/* ============================================================
   Admin Panel CSS — Kevin Mandon Photography
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:          #0f1117;
    --bg-2:        #171b24;
    --bg-3:        #1e2330;
    --bg-4:        #252b3b;
    --text:        #e8eaf0;
    --text-muted:  #7a8099;
    --accent:      #6366f1;
    --accent-h:    #818cf8;
    --success:     #22c55e;
    --error:       #ef4444;
    --warning:     #f59e0b;
    --border:      #2a3040;
    --sidebar-w:   240px;
    --font:        'Inter', sans-serif;
    --radius:      8px;
    --transition:  .2s ease;
}

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a { color: var(--accent-h); text-decoration: none; }
a:hover { color: var(--text); }
img { display: block; max-width: 100%; }
input, textarea, select, button { font-family: var(--font); }
code {
    background: var(--bg-4);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: .8rem;
    color: var(--accent-h);
}

/* ================================================================
   LOGIN PAGE
   ================================================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 0 24px;
}

.login-logo {
    text-align: center;
    margin-bottom: 40px;
}
.login-logo span {
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: .04em;
    display: block;
}
.login-logo p {
    font-size: .8rem;
    color: var(--text-muted);
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-top: 4px;
}

.login-form {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}

.login-back {
    text-align: center;
    margin-top: 20px;
    font-size: .85rem;
    color: var(--text-muted);
}

/* ================================================================
   LAYOUT
   ================================================================ */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    transition: transform var(--transition);
    overflow-y: auto;
}
.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand > span {
    width: 40px; height: 40px;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: .9rem;
    flex-shrink: 0;
}
.sidebar-site {
    font-weight: 600;
    font-size: .85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-role {
    font-size: .75rem;
    color: var(--text-muted);
    letter-spacing: .06em;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}
.nav-section {
    font-size: .7rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 8px 6px;
    margin-top: 8px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    font-size: .875rem;
    color: var(--text-muted);
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
}
.nav-item:hover {
    background: var(--bg-3);
    color: var(--text);
}
.nav-item.active {
    background: rgba(99, 102, 241, .15);
    color: var(--accent-h);
}
.nav-icon { font-style: normal; font-size: 1rem; width: 20px; text-align: center; }
.nav-logout { color: #ef4444 !important; margin-top: 8px; }
.nav-logout:hover { background: rgba(239, 68, 68, .1) !important; }

/* ---- Main ---- */
.admin-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Topbar ---- */
.topbar {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.topbar-user {
    font-size: .85rem;
    color: var(--text-muted);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 8px;
    display: none;
    transition: color var(--transition);
}
.sidebar-toggle:hover { color: var(--text); }

/* ---- Page content ---- */
.admin-page {
    padding: 32px 24px;
    max-width: 1200px;
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-title h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.badge {
    font-size: .75rem;
    background: var(--bg-4);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 500;
}

/* ================================================================
   STATS
   ================================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-h);
}
.stat-label {
    font-size: .85rem;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: .06em;
}
.stat-action {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ================================================================
   CARDS
   ================================================================ */
.card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
}
.card-header-link {
    font-size: .8rem;
    color: var(--text-muted);
}
.card-body { padding: 20px; }

/* ================================================================
   FORMULAIRES
   ================================================================ */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-muted);
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: .9rem;
    transition: border-color var(--transition);
    outline: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
}
.form-group textarea { resize: vertical; }
.form-hint {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 8px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-check label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text);
    font-weight: 400;
}
.form-check input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
}
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

/* ================================================================
   BOUTONS
   ================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); color: #fff; }
.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-outline:hover { border-color: var(--text-muted); color: var(--text); }
.btn-danger {
    background: rgba(239,68,68,.1);
    color: #ef4444;
    border-color: rgba(239,68,68,.3);
}
.btn-danger:hover { background: #ef4444; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: .85rem;
    color: var(--text-muted);
    transition: color var(--transition), background var(--transition);
}
.btn-icon:hover { background: var(--bg-4); color: var(--text); }
.btn-icon.btn-danger:hover { background: rgba(239,68,68,.15); color: #ef4444; }

/* ================================================================
   ALERTES
   ================================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 20px;
    border: 1px solid transparent;
}
.alert-success { background: rgba(34,197,94,.1); color: var(--success); border-color: rgba(34,197,94,.3); }
.alert-error   { background: rgba(239,68,68,.1); color: var(--error);   border-color: rgba(239,68,68,.3); }
.alert-warning { background: rgba(245,158,11,.1); color: var(--warning); border-color: rgba(245,158,11,.3); }

/* ================================================================
   DROPZONE
   ================================================================ */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent);
    background: rgba(99,102,241,.05);
}
.dropzone-icon { font-size: 2.5rem; margin-bottom: 12px; }
.dropzone p { color: var(--text-muted); margin: 4px 0; }
.dropzone-sub { font-size: .85rem; }
.upload-label { color: var(--accent-h); cursor: pointer; }
.upload-label:hover { text-decoration: underline; }

.upload-queue {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.upload-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-3);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.upload-item-thumb {
    width: 48px; height: 48px;
    object-fit: cover;
    border-radius: 4px;
}
.upload-item-name { flex: 1; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item-status { font-size: .8rem; white-space: nowrap; }
.upload-item-status.ok   { color: var(--success); }
.upload-item-status.err  { color: var(--error); }
.upload-progress {
    height: 3px;
    background: var(--bg-4);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}
.upload-progress-bar {
    height: 100%;
    background: var(--accent);
    transition: width .3s ease;
}

/* ================================================================
   GRILLE PHOTOS ADMIN
   ================================================================ */
.photo-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.photo-admin-item {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition);
}
.photo-admin-item:hover { border-color: var(--accent); }
.photo-admin-item.is-featured { border-color: var(--warning); }

.photo-admin-img {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: var(--bg-3);
}
.photo-admin-img img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform .3s ease;
}
.photo-admin-item:hover .photo-admin-img img { transform: scale(1.05); }

.badge-featured {
    position: absolute;
    top: 8px; right: 8px;
    background: var(--warning);
    color: #000;
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
}

.photo-admin-info {
    padding: 10px 12px 4px;
}
.photo-name {
    font-size: .85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.photo-name em { color: var(--text-muted); }
.photo-album {
    font-size: .75rem;
    color: var(--accent-h);
    margin-top: 2px;
}
.photo-admin-actions {
    padding: 8px 12px 12px;
    display: flex;
    gap: 8px;
}

/* Miniatures dashboard */
.thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}
.thumb-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-3);
}
.thumb-item img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.thumb-actions {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transition: opacity var(--transition);
}
.thumb-item:hover .thumb-actions { opacity: 1; }

/* ================================================================
   TABLEAU
   ================================================================ */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.admin-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: .75rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.admin-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg-3); }

/* ================================================================
   FORMULAIRE ÉDITION PHOTO
   ================================================================ */
.edit-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    align-items: start;
}
.edit-preview img {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* Albums admin layout */
.albums-admin-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
}

/* Cover picker */
.cover-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
}
.cover-option {
    width: 64px; height: 64px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color var(--transition);
    position: relative;
}
.cover-option.selected,
.cover-option:has(input:checked) { border-color: var(--accent); }
.cover-option input { position: absolute; opacity: 0; }
.cover-option img { width: 100%; height: 100%; object-fit: cover; }

/* ================================================================
   ÉTAT VIDE ADMIN
   ================================================================ */
.empty-state-admin {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: .9rem;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .albums-admin-layout { grid-template-columns: 1fr; }
    .edit-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .admin-page { padding: 20px 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .photo-admin-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
