/* ============================================================
   DeckManager — Casino Felt Theme
   ============================================================ */

/* --- Variables --- */
:root {
    --felt: #1a3a2a;
    --felt-light: #224733;
    --felt-dark: #0f2218;
    --gold: #c9973a;
    --gold-light: #e8b84b;
    --gold-pale: #f0d080;
    --cream: #f5eed8;
    --cream-dim: #d4c89a;
    --red: #c0392b;
    --red-light: #e74c3c;
    --panel-bg: rgba(10, 25, 18, 0.82);
    --panel-border: rgba(201, 151, 58, 0.25);
    --panel-border-bright: rgba(201, 151, 58, 0.55);
    --white: #ffffff;
    --muted: rgba(245, 238, 216, 0.45);
    --shadow-card: 0 4px 18px rgba(0,0,0,0.55), 0 1px 4px rgba(0,0,0,0.4);
    --shadow-panel: 0 8px 32px rgba(0,0,0,0.5);
    --radius: 10px;
    --radius-card: 8px;
    --font-display: 'Georgia', 'Times New Roman', serif;
    --font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    color: var(--cream);
    min-height: 100vh;
    background: var(--felt-dark);
    overflow-x: hidden;
    position: relative;
}

/* --- Felt Background --- */
.felt-bg {
    position: fixed; inset: 0; z-index: 0;
    background:
        radial-gradient(ellipse at 30% 20%, #2a5c3f 0%, transparent 55%),
        radial-gradient(ellipse at 80% 80%, #1a4030 0%, transparent 50%),
        linear-gradient(160deg, #1a3a2a 0%, #0f2218 100%);
}

.noise-overlay {
    position: fixed; inset: 0; z-index: 1; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    opacity: 0.4;
}

/* --- Header --- */
.app-header {
    position: sticky; top: 0; z-index: 100;
    background: linear-gradient(to bottom, rgba(8,18,13,0.97), rgba(8,18,13,0.85));
    border-bottom: 1px solid var(--panel-border-bright);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.header-inner {
    max-width: 1400px; margin: 0 auto;
    padding: 0.7rem 1.5rem;
    display: flex; align-items: center; gap: 1.5rem;
}

.logo {
    text-decoration: none;
    display: flex; align-items: center; gap: 0.5rem;
}

.logo-suits {
    color: var(--gold); font-size: 0.9rem; letter-spacing: 0.15em;
}

.logo-text {
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: var(--cream);
    letter-spacing: 0.04em;
    font-weight: bold;
}

.logo-text em {
    font-style: normal;
    color: var(--gold);
}

.breadcrumb {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.88rem; color: var(--muted);
}

.breadcrumb a {
    color: var(--gold); text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb a:hover { color: var(--gold-light); }

.breadcrumb-sep { opacity: 0.4; }

.breadcrumb-current { color: var(--cream); }

/* --- Main Content --- */
.main-content {
    position: relative; z-index: 2;
    max-width: 1400px; margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

/* ============================================================
   SCREEN 1 — Deck List
   ============================================================ */

.screen-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap; gap: 1rem;
}

.screen-title {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--gold-pale);
    letter-spacing: 0.05em;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* Deck Grid */
.deck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

.deck-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-panel);
}

.deck-card:hover {
    transform: translateY(-3px);
    border-color: var(--panel-border-bright);
    box-shadow: 0 12px 40px rgba(0,0,0,0.65);
}

.deck-card-inner {
    padding: 1.5rem;
}

.deck-preview {
    display: flex; justify-content: center;
    margin-bottom: 1rem;
    height: 70px;
    align-items: flex-end;
}

.deck-preview-stack { position: relative; width: 50px; height: 68px; }

.deck-preview-card {
    position: absolute;
    width: 44px; height: 64px;
    border-radius: 5px;
    background: var(--cream);
    border: 1px solid rgba(0,0,0,0.2);
    box-shadow: var(--shadow-card);
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(201, 151, 58, 0.08) 4px,
        rgba(201, 151, 58, 0.08) 8px
    );
}

.dc1 { left: 12px; top: 0; transform: rotate(-3deg); z-index: 3; background: var(--cream); }
.dc2 { left: 6px; top: 3px; transform: rotate(-7deg); z-index: 2; background: #ede5c8; }
.dc3 { left: 0px; top: 6px; transform: rotate(-11deg); z-index: 1; background: #e0d8b8; }

.deck-info { text-align: center; }

.deck-name {
    font-family: var(--font-display);
    font-size: 1.15rem;
    color: var(--cream);
    margin-bottom: 0.3rem;
    word-break: break-word;
}

.deck-count { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 0.4rem; }

.count-badge {
    display: inline-block;
    background: var(--gold);
    color: var(--felt-dark);
    font-weight: bold;
    font-size: 0.8rem;
    padding: 0.1rem 0.45rem;
    border-radius: 20px;
    min-width: 24px;
    text-align: center;
}

.deck-actions {
    display: flex; gap: 0.5rem; padding: 0.75rem 1rem;
    border-top: 1px solid var(--panel-border);
    background: rgba(0,0,0,0.25);
    flex-wrap: wrap;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 5rem 2rem;
    color: var(--muted);
}

.empty-icon { font-size: 4rem; margin-bottom: 1rem; display: block; }

.empty-state h2 {
    font-family: var(--font-display);
    color: var(--cream-dim);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.empty-state p { margin-bottom: 1.5rem; }

.empty-deck {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}

/* ============================================================
   SCREEN 2 — Deck View
   ============================================================ */

.deck-status-bar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border-bright);
    border-radius: var(--radius);
    padding: 0.9rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-panel);
}

.status-info { display: flex; align-items: center; gap: 0.75rem; }

.status-label { color: var(--muted); font-size: 0.85rem; }

.status-name {
    font-family: var(--font-display);
    color: var(--gold-pale);
    font-size: 1.1rem;
}

.status-count { display: flex; align-items: baseline; gap: 0.4rem; }

.big-count {
    font-family: var(--font-display);
    font-size: 2.2rem;
    color: var(--gold);
    line-height: 1;
    font-weight: bold;
}

.count-label { color: var(--muted); font-size: 0.85rem; }

/* Layout 3 colonnes */
.screen2-layout {
    display: grid;
    grid-template-columns: 240px 1fr 220px;
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 1000px) {
    .screen2-layout {
        grid-template-columns: 1fr 1fr;
    }
    .deck-section { grid-column: 1 / -1; order: -1; }
}

@media (max-width: 640px) {
    .screen2-layout { grid-template-columns: 1fr; }
    .deck-section { order: 0; }
}

/* Panels */
.actions-panel, .catalog-panel, .deck-section {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-panel);
}

.panel-title {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--gold-pale);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.82rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--panel-border);
}

/* Action Cards */
.action-card {
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-card);
    padding: 1rem;
    margin-bottom: 0.85rem;
}

.action-card-draw { border-color: rgba(201, 151, 58, 0.4); }

.action-title {
    font-size: 0.9rem;
    color: var(--cream);
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.action-desc { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.75rem; line-height: 1.4; }

.action-form { }

.form-row {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}

/* Draw Result */
.draw-result {
    margin-top: 1rem;
    text-align: center;
}

.draw-result.hidden { display: none; }

.drawn-card-display { margin-bottom: 0.75rem; }

.drawn-card-img {
    width: 80px;
    border-radius: 5px;
    box-shadow: var(--shadow-card);
    display: block; margin: 0 auto 0.5rem;
    transition: transform 0.3s;
}

.drawn-card-img:hover { transform: scale(1.05); }

.drawn-name { font-size: 0.9rem; color: var(--cream); font-weight: 600; }

.draw-choices { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }

/* Sort bar */
.deck-section-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--panel-border);
}

.sort-form { display: flex; align-items: center; gap: 0.4rem; }

.sort-label { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }

.sort-btns { display: flex; gap: 0.3rem; }

.sort-btn {
    padding: 0.22rem 0.6rem;
    border-radius: 5px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--panel-border);
    color: var(--cream); cursor: pointer;
    font-size: 0.78rem; font-family: var(--font-body);
    transition: all 0.15s;
    white-space: nowrap;
}

.sort-btn:hover { background: rgba(255,255,255,0.12); }

.sort-btn.active {
    background: var(--gold);
    color: var(--felt-dark);
    border-color: var(--gold);
    font-weight: 600;
}

/* Deck Cards Grid */
.deck-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    gap: 0.5rem;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.deck-cards-grid::-webkit-scrollbar { width: 5px; }
.deck-cards-grid::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 3px; }
.deck-cards-grid::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; opacity: 0.5; }

.card-item {
    position: relative;
    border-radius: 5px;
    overflow: visible;
    transition: transform 0.15s;
}

.card-item:hover { transform: scale(1.06); z-index: 5; }

.card-img {
    display: block;
    width: 100%;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.card-remove-form {
    position: absolute; top: -5px; right: -5px;
    opacity: 0;
    transition: opacity 0.15s;
}

.card-item:hover .card-remove-form { opacity: 1; }

.card-remove-btn {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--red);
    color: white; border: none;
    cursor: pointer; font-size: 0.65rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    transition: background 0.15s;
    line-height: 1;
}

.card-remove-btn:hover { background: var(--red-light); }

/* Catalog */
.catalog-filter { margin-bottom: 0.75rem; }

.suit-filters {
    display: flex; gap: 0.3rem; flex-wrap: wrap;
    margin-top: 0.5rem;
}

.suit-btn {
    padding: 0.25rem 0.5rem;
    border-radius: 5px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--panel-border);
    color: var(--cream); cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.15s;
}

.suit-btn:hover { background: rgba(255,255,255,0.12); }
.suit-btn.active { background: var(--gold); color: var(--felt-dark); border-color: var(--gold); font-weight: bold; }
.suit-btn.heart, .suit-btn.diamond { color: var(--red-light); }
.suit-btn.joker { font-size: 0.75rem; }

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
    gap: 0.4rem;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 0.2rem;
}

.catalog-grid::-webkit-scrollbar { width: 4px; }
.catalog-grid::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; }

.catalog-item { display: block; }

.catalog-card-btn {
    width: 100%; border: none; background: transparent; cursor: pointer; padding: 0;
    display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
    border-radius: 5px;
    transition: transform 0.15s;
}

.catalog-card-btn:hover { transform: scale(1.08); }

.catalog-card-img {
    width: 100%;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.45);
    display: block;
}

.catalog-card-label {
    font-size: 0.62rem; color: var(--muted);
    display: flex; gap: 0.2rem; align-items: center;
    white-space: nowrap;
}

.catalog-suit.red { color: var(--red-light); }
.catalog-suit.joker { font-size: 0.65rem; }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.35rem; padding: 0.5rem 1rem;
    border-radius: 6px; border: 1px solid transparent;
    font-family: var(--font-body);
    font-size: 0.85rem; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: all 0.18s;
    white-space: nowrap;
}

.btn-icon { font-size: 1rem; font-weight: 400; }

.btn-primary {
    background: var(--gold);
    color: var(--felt-dark);
    border-color: var(--gold);
}

.btn-primary:hover {
    background: var(--gold-light);
    border-color: var(--gold-light);
    box-shadow: 0 2px 10px rgba(201,151,58,0.4);
}

.btn-secondary {
    background: rgba(255,255,255,0.08);
    color: var(--cream);
    border-color: rgba(255,255,255,0.18);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.3);
}

.btn-danger {
    background: transparent;
    color: #e07070;
    border-color: rgba(192, 57, 43, 0.4);
}

.btn-danger:hover {
    background: rgba(192, 57, 43, 0.18);
    border-color: var(--red);
    color: #ff9090;
}

.btn-accent {
    background: linear-gradient(135deg, #2a7a4f, #1a5c3a);
    color: var(--gold-pale);
    border-color: rgba(201, 151, 58, 0.4);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.btn-accent:hover {
    background: linear-gradient(135deg, #35a065, #206b45);
    border-color: var(--gold);
    box-shadow: 0 3px 14px rgba(0,0,0,0.4);
}

.btn-accent:disabled {
    opacity: 0.4; cursor: not-allowed;
}

.btn-large { padding: 0.65rem 1.4rem; font-size: 0.95rem; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* ============================================================
   FORMS
   ============================================================ */

.form-label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem; }

.form-input {
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    color: var(--cream);
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    font-family: var(--font-body);
    width: 100%;
    transition: border-color 0.18s, box-shadow 0.18s;
    outline: none;
}

.form-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(201,151,58,0.2);
}

.form-input::placeholder { color: rgba(245,238,216,0.3); }

.input-sm { width: auto; min-width: 0; flex: 1 1 60px; max-width: 80px; }

/* Toggle */
.toggle-label {
    display: flex; align-items: center; gap: 0.5rem;
    cursor: pointer; font-size: 0.8rem; color: var(--muted);
    user-select: none;
}

.toggle-cb { display: none; }

.toggle-track {
    width: 32px; height: 18px;
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--panel-border);
    border-radius: 9px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.2s, background 0.2s;
}

.toggle-cb:checked + .toggle-track { background: rgba(201, 151, 58, 0.35); border-color: var(--gold); }
.toggle-cb:checked + .toggle-track::after { transform: translateX(14px); background: var(--gold); }

.text-muted { color: var(--muted); font-size: 0.85rem; margin-top: 0.3rem; }

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center; justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
    background: linear-gradient(160deg, #1a3a2a 0%, #0f2218 100%);
    border: 1px solid var(--panel-border-bright);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.7);
    width: 90%; max-width: 420px;
    animation: modal-in 0.2s ease;
}

.modal-sm { max-width: 320px; }

@keyframes modal-in {
    from { opacity: 0; transform: translateY(-12px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--panel-border);
}

.modal-header h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--gold-pale);
}

.modal-close {
    background: none; border: none; color: var(--muted);
    font-size: 1rem; cursor: pointer; padding: 0.2rem;
    transition: color 0.15s;
}

.modal-close:hover { color: var(--cream); }

.modal-body { padding: 1.25rem; }

.modal-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--panel-border);
    display: flex; gap: 0.5rem; justify-content: flex-end;
}

/* ============================================================
   HISTORIQUE
   ============================================================ */

.history-card {
    border-color: rgba(201, 151, 58, 0.2);
}

.history-list {
    list-style: none;
    max-height: 210px;   /* ~8 lignes */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding-right: 0.2rem;
    counter-reset: history-counter;
}

.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; opacity: 0.5; }

.history-entry {
    font-size: 0.77rem;
    color: var(--cream-dim);
    line-height: 1.4;
    padding: 0.3rem 0.5rem;
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
    border-left: 2px solid var(--gold);
    opacity: 0.85;
    /* entrée la plus récente en haut, légèrement plus visible */
}

.history-entry:first-child {
    opacity: 1;
    color: var(--cream);
    border-left-color: var(--gold-light);
}

.history-empty {
    font-size: 0.78rem;
    color: var(--muted);
    font-style: italic;
    text-align: center;
    padding: 0.5rem 0;
}
