/* ============================================================
   Shop Sui Juris - Theme E-commerce
   Inspire du design slides "Votre Desequilibre Les Arrange"
   Palette: dark (#0d0d1a) + gold (#c9a84c) + accent (#e94560)
   ============================================================ */

:root {
    --bg-dark: #0d0d1a;
    --bg-card: #1a1a2e;
    --bg-input: #16213e;
    --bg-hover: #222244;
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0b0;
    --text-muted: #666680;
    --gold: #c9a84c;
    --gold-dark: #a08030;
    --accent: #e94560;
    --green: #2d6a4f;
    --green-light: #7ddf9e;
    --blue: #3498db;
    --border: #2a2a40;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --max-width: 1200px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--text-primary); }
img { max-width: 100%; height: auto; }

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
    background: rgba(13, 13, 26, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 20px;
}
.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
}
.brand-icon { font-size: 24px; }
.nav-menu {
    display: flex;
    align-items: center;
    gap: 6px;
}
.nav-link {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}
.nav-link:hover, .nav-link.active { color: var(--text-primary); background: var(--bg-hover); }
.nav-link.nav-cta {
    background: var(--gold);
    color: var(--bg-dark);
    font-weight: 600;
}
.nav-link.nav-cta:hover { background: var(--gold-dark); color: var(--bg-dark); }
.nav-link.nav-admin { color: var(--accent); }
.nav-cart { position: relative; }
.cart-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.credits-badge {
    display: inline-block;
    background: var(--green);
    color: var(--green-light);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
}

/* Dropdown */
.nav-dropdown { position: relative; display: flex; align-items: center; }
.nav-user-btn {
    background: none;
    border: 1px solid var(--border);
    cursor: pointer;
    font-family: inherit;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    line-height: 1.4;
    transition: all 0.2s;
}
.nav-user-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 200px;
    padding: 8px 0;
    box-shadow: var(--shadow);
    z-index: 200;
}
.nav-dropdown:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: 14px;
}
.nav-dropdown-menu a:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-dropdown-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* Mobile toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}
.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    margin: 5px 0;
    transition: 0.3s;
}

/* Mobile: voir bloc complet en fin de fichier */

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    flex: 1;
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    padding: 30px 20px;
}

/* ============================================================
   CARDS / GRID
   ============================================================ */
.ebook-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
}
.ebook-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.ebook-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(201, 168, 76, 0.15);
}
.ebook-card-cover {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--bg-input);
}
.ebook-card-body { padding: 16px; }
.ebook-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ebook-card-author { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.ebook-card-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
}
.ebook-card-price small { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.ebook-card-rating { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.star { color: var(--gold); font-size: 14px; }
.star.empty { color: var(--text-muted); }
.ebook-card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ebook-card-category {
    font-size: 11px;
    padding: 3px 8px;
    background: var(--bg-hover);
    border-radius: 10px;
    color: var(--text-muted);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary { background: var(--gold); color: var(--bg-dark); }
.btn-primary:hover { background: var(--gold-dark); color: var(--bg-dark); }
.btn-secondary { background: var(--bg-hover); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--gold); }
.btn-danger { background: var(--accent); color: white; }
.btn-success { background: var(--green); color: white; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--gold);
    outline: none;
}
.form-group textarea { min-height: 120px; resize: vertical; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a0a0b0'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* Role selector */
.role-selector { display: flex; gap: 16px; }
.role-option { flex: 1; cursor: pointer; }
.role-option input { display: none; }
.role-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.2s;
    text-align: center;
}
.role-option input:checked + .role-card {
    border-color: var(--gold);
    background: rgba(201, 168, 76, 0.1);
}
.role-icon { font-size: 28px; }
.role-card strong { color: var(--text-primary); }
.role-card small { color: var(--text-muted); font-size: 12px; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error { background: #3d1c1c; border: 1px solid var(--accent); color: #ff8a8a; }
.alert-success { background: #1c3d2a; border: 1px solid var(--green); color: var(--green-light); }
.alert-warning { background: #3d3a1c; border: 1px solid var(--gold); color: #ffd666; }
.alert-info { background: #1c2a3d; border: 1px solid var(--blue); color: #8ac4ff; }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-container {
    display: flex;
    justify-content: center;
    padding: 40px 20px;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow);
}
.auth-card-wide { max-width: 600px; }
.auth-card h1 {
    text-align: center;
    color: var(--gold);
    margin-bottom: 4px;
}
.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 24px;
}
.auth-form { margin-top: 20px; }
.auth-links {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
}
.auth-links a { color: var(--gold); }
.separator { color: var(--text-muted); margin: 0 8px; }

/* ============================================================
   HERO SECTION (Homepage)
   ============================================================ */
.hero {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-dark) 100%);
    border-radius: var(--radius);
    margin-bottom: 40px;
    border: 1px solid var(--border);
}
.hero h1 {
    font-size: 36px;
    color: var(--gold);
    margin-bottom: 12px;
}
.hero p {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 24px;
}
.hero-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 30px;
}
.hero-stat { text-align: center; }
.hero-stat-number { font-size: 28px; font-weight: 700; color: var(--gold); display: block; }
.hero-stat-label { font-size: 13px; color: var(--text-muted); }

/* ============================================================
   SECTION HEADINGS
   ============================================================ */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.section-header h2 { font-size: 22px; color: var(--text-primary); }
.section-header a { font-size: 14px; }

/* ============================================================
   CATEGORY TILES
   ============================================================ */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 40px;
}
.category-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.2s;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}
.category-tile:hover {
    border-color: var(--gold);
    color: var(--gold);
    transform: translateY(-2px);
}
.category-tile-icon { font-size: 28px; }

/* ============================================================
   PRODUCT PAGE
   ============================================================ */
.product-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 40px;
    margin-bottom: 40px;
}
.product-cover {
    width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--bg-card);
}
.product-info h1 { font-size: 28px; margin-bottom: 8px; }
.product-author { font-size: 16px; color: var(--text-muted); margin-bottom: 16px; }
.product-price {
    font-size: 32px;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 20px;
}
.product-price small { font-size: 14px; color: var(--text-muted); font-weight: 400; }
.product-formats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.format-badge {
    padding: 4px 12px;
    background: var(--bg-hover);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}
.product-description {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 24px;
}
.product-actions { display: flex; gap: 12px; flex-wrap: wrap; }

@media (max-width: 768px) {
    .product-layout { grid-template-columns: 1fr; }
    .hero h1 { font-size: 26px; }
    .hero-stats { flex-wrap: wrap; gap: 20px; }
}

/* ============================================================
   TABLES
   ============================================================ */
.table-container { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
}
th, td { padding: 12px 16px; text-align: left; font-size: 14px; }
th {
    background: var(--bg-hover);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
td { border-bottom: 1px solid var(--border); }
tr:hover td { background: rgba(201, 168, 76, 0.03); }

/* ============================================================
   BLOCKCHAIN VIEWER
   ============================================================ */
.blockchain-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
    position: relative;
}
.blockchain-block::before {
    content: '';
    position: absolute;
    left: 30px;
    top: -12px;
    width: 2px;
    height: 12px;
    background: var(--gold);
}
.blockchain-block:first-child::before { display: none; }
.block-number {
    display: inline-block;
    background: var(--gold);
    color: var(--bg-dark);
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
}
.block-hash {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
    background: var(--bg-input);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    margin: 4px 0;
}
.block-info { font-size: 14px; color: var(--text-secondary); }
.block-verified { color: var(--green-light); font-weight: 600; }
.block-corrupted { color: var(--accent); font-weight: 600; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 30px;
}
.pagination a, .pagination span {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
}
.pagination a:hover { border-color: var(--gold); color: var(--gold); }
.pagination .active {
    background: var(--gold);
    color: var(--bg-dark);
    border-color: var(--gold);
    font-weight: 600;
}

/* ============================================================
   BADGE / STATUS
   ============================================================ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}
.badge-success { background: rgba(45, 106, 79, 0.2); color: var(--green-light); }
.badge-warning { background: rgba(201, 168, 76, 0.2); color: var(--gold); }
.badge-danger { background: rgba(233, 69, 96, 0.2); color: var(--accent); }
.badge-info { background: rgba(52, 152, 219, 0.2); color: var(--blue); }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 40px 20px 20px;
    margin-top: 60px;
}
.footer-container { max-width: var(--max-width); margin: 0 auto; }
.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}
.footer-col h4 { color: var(--gold); margin-bottom: 12px; font-size: 15px; }
.footer-col p, .footer-col a {
    display: block;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 6px;
}
.footer-col a:hover { color: var(--gold); }
.footer-stat { font-size: 13px !important; }
.footer-bottom {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ============================================================
   SEARCH
   ============================================================ */
.search-box {
    display: flex;
    gap: 0;
    max-width: 600px;
    margin: 0 auto 30px;
}
.search-box input {
    flex: 1;
    padding: 12px 20px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    color: var(--text-primary);
    font-size: 15px;
}
.search-box input:focus { border-color: var(--gold); outline: none; }
.search-box button {
    padding: 12px 24px;
    background: var(--gold);
    color: var(--bg-dark);
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-weight: 600;
    cursor: pointer;
    font-size: 15px;
}

/* ============================================================
   UTILITY
   ============================================================ */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-gold { color: var(--gold); }
.text-accent { color: var(--accent); }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.mb-40 { margin-bottom: 40px; }
.flex { display: flex; }
.flex-between { justify-content: space-between; }
.flex-center { align-items: center; }
.gap-12 { gap: 12px; }
.hidden { display: none; }

/* ============================================================
   THEME CLAIR
   ============================================================ */
[data-theme="light"] {
    --bg-dark: #f5f5f5;
    --bg-card: #ffffff;
    --bg-input: #f0f0f0;
    --bg-hover: #e8e8f0;
    --text-primary: #1a1a2e;
    --text-secondary: #555566;
    --text-muted: #888899;
    --border: #d0d0dd;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
}
[data-theme="light"] .navbar {
    background: rgba(255,255,255,0.95);
    border-bottom-color: #d0d0dd;
}
[data-theme="light"] .footer {
    background: #ffffff;
    border-top-color: #d0d0dd;
}
[data-theme="light"] .block-hash {
    background: #f0f0f0;
}

/* Theme toggle button */
#theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.4;
    transition: all 0.2s;
}
#theme-toggle:hover { border-color: var(--gold); }

/* ============================================================
   RESPONSIVE FIX
   ============================================================ */
@media (max-width: 768px) {
    /* Casser le stacking context de la navbar pour liberer le menu */
    .navbar {
        position: relative;
        backdrop-filter: none;
        z-index: auto;
    }
    .nav-toggle { display: block !important; }
    .nav-menu {
        display: none !important;
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-dark);
        flex-direction: column;
        padding: 20px;
        gap: 4px;
        overflow-y: auto;
        z-index: 99999;
    }
    .nav-menu.open { display: flex !important; }
    .nav-link { padding: 14px 16px; width: 100%; font-size: 16px; line-height: 1.4; }
    #theme-toggle { width: 100%; padding: 14px 16px; text-align: left; font-size: 16px; line-height: 1.4; border: none; border-bottom: 1px solid var(--border); border-radius: 0; }
    .nav-dropdown { width: 100%; display: block; }
    .nav-dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        background: var(--bg-hover);
        border-radius: var(--radius);
        display: block;
        margin-top: 4px;
    }
    .nav-dropdown:hover .nav-dropdown-menu { display: block; }
    .nav-user-btn { width: 100%; text-align: left; padding: 14px 16px; font-size: 16px; line-height: 1.4; border: none; border-bottom: 1px solid var(--border); border-radius: 0; }

    .main-content { padding: 16px 12px; }
    .hero { padding: 30px 16px; }
    .hero h1 { font-size: 22px; }
    .hero p { font-size: 15px; }
    .hero-stats { gap: 16px; }
    .product-layout { grid-template-columns: 1fr; gap: 20px; }
    .ebook-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
    .category-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
    .auth-card { padding: 24px 16px; }
    .form-row { flex-direction: column; gap: 0; }
    .section-header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .search-box { flex-direction: column; }
    .search-box input { border-right: 1px solid var(--border); border-radius: var(--radius); }
    .search-box button { border-radius: var(--radius); }
    .footer-grid { grid-template-columns: 1fr; }
    table { font-size: 13px; }
    th, td { padding: 8px 10px; }
}
