/* ============================================================
   ROTSIKA — Charte Graphique
   Couleurs: #1A6B3C (vert), #0D2B1A (nuit), #F5A623 (or), #E8F5ED (clair)
   ============================================================ */

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

:root {
    --primary: #1A6B3C;
    --primary-dark: #0D2B1A;
    --accent: #F5A623;
    --light: #E8F5ED;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --danger: #dc2626;
    --warning: #f59e0b;
    --success: #16a34a;
    --info: #2563eb;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-family: Georgia, 'Times New Roman', serif; color: var(--primary-dark); }

/* ---- AUTH PAGES ---- */
.auth-body {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.auth-container {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo h1 {
    font-size: 2.2rem;
    color: var(--primary);
    letter-spacing: 2px;
}

.auth-logo .tagline {
    color: var(--accent);
    font-size: 0.85rem;
    font-style: italic;
    margin-top: 0.3rem;
}

/* ---- STEPS INDICATOR ---- */
.steps {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.step-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--gray-200);
    color: var(--gray-500);
    transition: all 0.3s;
}

.step-dot.active {
    background: var(--primary);
    color: var(--white);
}

.step-dot.done {
    background: var(--accent);
    color: var(--white);
}

/* ---- FORMS ---- */
.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s;
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,107,60,0.1);
}

.form-control.error {
    border-color: var(--danger);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

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

.form-text {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

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

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn-primary {
    background: var(--primary);
    color: var(--white);
}
.btn-primary:hover { background: #155731; }

.btn-accent {
    background: var(--accent);
    color: var(--white);
}
.btn-accent:hover { background: #d4901e; }

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--light); }

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.btn-success { background: var(--success); color: var(--white); }

/* ---- ALERTS ---- */
.alert {
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border-left: 4px solid;
}

.alert-danger { background: #fef2f2; color: var(--danger); border-color: var(--danger); }
.alert-success { background: #f0fdf4; color: var(--success); border-color: var(--success); }
.alert-warning { background: #fffbeb; color: #92400e; border-color: var(--warning); }
.alert-info { background: #eff6ff; color: var(--info); border-color: var(--info); }

/* ---- MAIN LAYOUT ---- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--primary-dark);
    color: var(--white);
    padding: 1.5rem 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-logo {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.sidebar-logo h2 {
    color: var(--accent);
    font-size: 1.5rem;
    letter-spacing: 2px;
}

.sidebar-logo small {
    color: rgba(255,255,255,0.6);
    font-size: 0.75rem;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.5rem;
    color: rgba(255,255,255,0.7);
    font-size: 0.95rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
    text-decoration: none;
}

.nav-item.active {
    background: rgba(255,255,255,0.1);
    color: var(--accent);
    border-left-color: var(--accent);
}

.nav-item .nav-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}

.main-content {
    margin-left: 260px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    background: var(--white);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar-left h2 {
    font-size: 1.3rem;
    margin: 0;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: var(--light);
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--primary-dark);
    font-weight: 600;
}

.page-content {
    padding: 2rem;
    flex: 1;
}

/* ---- FOOTER ---- */
.app-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--gray-200);
    margin-top: auto;
}
.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--gray-500);
}
.footer-links {
    display: flex;
    gap: 1rem;
}
.footer-links a {
    color: var(--gray-500);
    text-decoration: none;
}
.footer-links a:hover {
    color: var(--primary);
}

/* ---- CARDS ---- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* ---- STAT CARDS (Dashboard) ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.green { background: var(--light); color: var(--primary); }
.stat-icon.gold { background: #fef3c7; color: var(--accent); }
.stat-icon.blue { background: #dbeafe; color: var(--info); }
.stat-icon.red { background: #fef2f2; color: var(--danger); }

.stat-info h3 {
    font-size: 1.6rem;
    font-family: -apple-system, sans-serif;
    margin-bottom: 0.15rem;
}

.stat-info p {
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* ---- WALLET CARD ---- */
.wallet-card {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.wallet-card::after {
    content: '';
    position: absolute;
    top: -30%;
    right: -10%;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(245,166,35,0.15);
}

.wallet-card .balance-label {
    font-size: 0.9rem;
    opacity: 0.8;
}

.wallet-card .balance {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.wallet-card .wallet-id {
    font-size: 0.85rem;
    opacity: 0.7;
    letter-spacing: 1px;
}

.wallet-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.wallet-actions .btn {
    background: rgba(255,255,255,0.2);
    color: var(--white);
    border: 1px solid rgba(255,255,255,0.3);
    flex: 1;
}

.wallet-actions .btn:hover {
    background: rgba(255,255,255,0.3);
}

/* ---- TABLES ---- */
.table-container {
    overflow-x: auto;
}

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

table th {
    background: var(--gray-50);
    padding: 0.8rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    border-bottom: 2px solid var(--gray-200);
}

table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
}

table tr:hover { background: var(--gray-50); }

/* ---- BADGES ---- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fef2f2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gold { background: #fef3c7; color: #92400e; }

/* ---- PROGRESS BAR ---- */
.progress {
    height: 8px;
    background: var(--gray-200);
    border-radius: 50px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 50px;
    transition: width 0.3s;
}

.progress-bar.gold { background: var(--accent); }

/* ---- GROUP CARD ---- */
.group-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.group-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    border-top: 4px solid var(--primary);
    transition: transform 0.2s;
}

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

.group-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }

.group-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.8rem 0;
}

.group-meta span {
    font-size: 0.8rem;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

/* ---- FORUM / CHAT ---- */
.chat-container {
    height: 500px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.chat-message {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
}

.chat-message .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.chat-message .msg-content {
    background: var(--light);
    padding: 0.6rem 1rem;
    border-radius: 0 12px 12px 12px;
    max-width: 70%;
}

.chat-message .msg-content .msg-author {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
}

.chat-message .msg-content .msg-time {
    font-size: 0.7rem;
    color: var(--gray-500);
}

.chat-message.system {
    justify-content: center;
}

.chat-message.system .msg-content {
    background: #fef3c7;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #92400e;
    text-align: center;
}

.chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--gray-200);
}

.chat-input input {
    flex: 1;
}

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray-500);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* ---- GRID HELPERS ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
        position: fixed;
        z-index: 1000;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .wallet-actions { flex-direction: column; }
    .group-grid { grid-template-columns: 1fr; }
    .page-content { padding: 1rem; }

    .mobile-menu-btn {
        display: block;
    }

    /* Top bar responsive */
    .top-bar {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }
    .top-bar-left h2 {
        font-size: 1rem;
    }
    .top-bar-right {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 0.5rem;
        font-size: 0.85rem;
    }

    /* Tables responsive — horizontal scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table {
        min-width: 600px;
    }
    table th, table td {
        padding: 0.5rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* Cards */
    .card {
        margin-left: -0.25rem;
        margin-right: -0.25rem;
        border-radius: var(--radius-sm);
    }

    /* Footer responsive */
    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    /* Flex-between on mobile */
    .flex-between {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Stat cards 2 columns on mobile */
    .stats-grid {
        gap: 0.75rem;
    }
    .stat-card {
        padding: 0.75rem;
    }
    .stat-card .value {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-content { padding: 0.75rem; }
    .top-bar-right .badge { font-size: 0.7rem; }
    .user-badge { font-size: 0.8rem; }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}
.sidebar-overlay.active {
    display: block;
}

@media (min-width: 769px) {
    .mobile-menu-btn { display: none; }
    .sidebar-overlay { display: none !important; }
}

/* ---- TIER BADGES ---- */
.tier-bronze { color: #92400e; }
.tier-silver { color: #6b7280; }
.tier-gold { color: #b45309; }
.tier-platinum { color: #4f46e5; }

/* ---- DARK MODE TOGGLE ---- */
.theme-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.7);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.theme-toggle:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ---- DARK MODE ---- */
[data-theme="dark"] {
    --gray-50: #111827;
    --gray-100: #1f2937;
    --gray-200: #374151;
    --gray-300: #4b5563;
    --gray-500: #9ca3af;
    --gray-700: #d1d5db;
    --gray-900: #f9fafb;
    --white: #1a1a2e;
    --light: #0f3d1f;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.3);
}

[data-theme="dark"] body,
[data-theme="dark"] .main-content {
    background: #0f1117;
    color: #e5e7eb;
}
[data-theme="dark"] .app-footer {
    border-color: #2d2d3d;
}
[data-theme="dark"] .footer-content,
[data-theme="dark"] .footer-links a {
    color: #6b7280;
}
[data-theme="dark"] .footer-links a:hover {
    color: #F5A623;
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4 {
    color: #a7f3d0;
}

[data-theme="dark"] .card {
    background: #1a1a2e;
    border-color: #2d2d44;
}

[data-theme="dark"] .card-header {
    background: #16162a;
    border-color: #2d2d44;
    color: #e5e7eb;
}

[data-theme="dark"] .form-control {
    background: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
}

[data-theme="dark"] .form-control:focus {
    border-color: var(--primary);
    background: #1f2937;
}

[data-theme="dark"] table {
    color: #e5e7eb;
}

[data-theme="dark"] table thead {
    background: #16162a;
}

[data-theme="dark"] table tbody tr {
    border-color: #2d2d44;
}

[data-theme="dark"] table tbody tr:hover {
    background: #1f2937;
}

[data-theme="dark"] .alert {
    border-color: #2d2d44;
}

[data-theme="dark"] .alert-success { background: #052e16; color: #86efac; }
[data-theme="dark"] .alert-danger { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .alert-warning { background: #422006; color: #fcd34d; }
[data-theme="dark"] .alert-info { background: #172554; color: #93c5fd; }

[data-theme="dark"] .stat-card {
    background: #1a1a2e;
    border-color: #2d2d44;
}

[data-theme="dark"] .top-bar {
    background: #1a1a2e;
    border-color: #2d2d44;
}

[data-theme="dark"] .wallet-card {
    background: linear-gradient(135deg, #0D2B1A 0%, #1A6B3C 50%, #0f3d1f 100%);
}

[data-theme="dark"] .auth-container {
    background: #1a1a2e;
    color: #e5e7eb;
}

[data-theme="dark"] .text-muted { color: #9ca3af !important; }

[data-theme="dark"] .btn-outline {
    border-color: #4b5563;
    color: #e5e7eb;
}

[data-theme="dark"] .btn-outline:hover {
    background: #374151;
}

[data-theme="dark"] .empty-state { color: #9ca3af; }

[data-theme="dark"] .chat-messages {
    background: #111827;
}

[data-theme="dark"] .chat-message .msg-content {
    background: #1f2937;
    color: #e5e7eb;
}

[data-theme="dark"] .chat-input {
    background: #1a1a2e;
    border-color: #2d2d44;
}

/* Badge notification pulse */
@keyframes badge-pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.4); }
    100% { transform: scale(1); }
}
.badge-pulse { animation: badge-pulse 0.4s ease-in-out; }
