:root {
    --primary-color: #6c5ce7;
    --secondary-color: #a29bfe;
    --success-color: #00b894;
    --danger-color: #d63031;
    --warning-color: #fdcb6e;
    --dark-bg: #2c3e50;
    --light-bg: #ecf0f1;
    --text-dark: #2c3e50;
    --text-light: #95a5a6;
    --border-radius: 12px;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.battles-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.battles-header {
    text-align: center;
    margin-bottom: 50px;
    animation: fadeIn 0.6s ease-in;
}

.battles-header h1 {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 18px;
    color: var(--text-light);
}

/* Create Battle Section */
.create-battle-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    margin-bottom: 50px;
}

.create-battle-card {
    background: white;
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.create-battle-card h2 {
    color: var(--primary-color);
    margin-bottom: 25px;
    font-size: 24px;
}

.battle-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

/* cacher l'ancien menu déroulant de sélection de case */
select#case_id {
    display: none;
}

.case-picker-trigger {
    display: flex;
    align-items: center;
    margin-top: 10px;
    gap: 10px;
}

.case-picker-selected {
    flex: 1;
    padding: 10px 12px;
    border-radius: 8px;
    border: 2px dashed #e0e0e0;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.case-picker-selected .placeholder {
    color: var(--text-light);
    font-size: 14px;
}

.selected-cases-list {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.selected-case-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #f1f2f6;
    font-size: 12px;
}

.selected-case-pill img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.selected-case-pill input[type="number"] {
    width: 50px;
    padding: 2px 4px;
    font-size: 12px;
}

.selected-case-remove {
    cursor: pointer;
    color: #e74c3c;
    font-weight: 700;
    margin-left: 4px;
}

.case-picker-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.case-picker-modal.open {
    display: flex;
}

.case-picker-modal-inner {
    background: #1e272e;
    border-radius: 12px;
    padding: 20px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.case-picker-modal-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
}

.case-picker-search {
    flex: 1;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #57606f;
    background: #2f3640;
    color: #f1f2f6;
}

.case-picker-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #ff4757;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}

.case-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    max-height: 420px;
    overflow-y: auto;
}

.case-card {
    background: #2f3640;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    border: 2px solid transparent;
}

.case-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
    border-color: var(--primary-color);
}

.case-card img {
    width: 100%;
    height: 90px;
    object-fit: contain;
    margin-bottom: 6px;
}

.case-card-name {
    color: #f1f2f6;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.case-card-price {
    color: var(--success-color);
    font-size: 13px;
}

.input-with-icon {
    position: relative;
}

.currency {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    font-weight: 600;
}

.btn-primary {
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(108, 92, 231, 0.3);
}

.btn-secondary {
    padding: 10px 18px;
    border-radius: 8px;
    border: 2px solid var(--primary-color);
    background: #ffffff;
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 10px;
}

.btn-secondary:hover {
    background: rgba(108, 92, 231, 0.1);
}

/* User Stats */
.user-stats {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    border-left: 5px solid var(--primary-color);
}

.stat-icon {
    font-size: 32px;
}

.stat-content {
    flex: 1;
}

.stat-label {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 5px;
}

.stat-value {
    color: var(--primary-color);
    font-size: 24px;
    font-weight: 700;
}

/* Login Prompt */
.login-prompt {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.1), rgba(162, 155, 254, 0.1));
    padding: 30px;
    border-radius: var(--border-radius);
    text-align: center;
    border: 2px dashed var(--primary-color);
    margin-bottom: 50px;
}

.login-prompt p {
    color: var(--text-dark);
    font-size: 16px;
}

.login-prompt a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.login-prompt a:hover {
    text-decoration: underline;
}

/* Battles List */
.battles-list-section h2 {
    color: var(--primary-color);
    margin-bottom: 30px;
    font-size: 28px;
}

.no-battles {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.no-battles p {
    color: var(--text-dark);
    font-size: 18px;
    margin-bottom: 10px;
}

.text-muted {
    color: var(--text-light);
    font-size: 14px;
}

/* Battles Grid */
.battles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
}

.battle-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.battle-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.15);
}

.battle-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.battle-id {
    color: white;
    font-size: 18px;
    font-weight: 700;
}

.battle-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.status-waiting {
    background: rgba(253, 203, 110, 0.3);
    color: #f39c12;
}

.status-running {
    background: rgba(214, 48, 49, 0.3);
    color: #d63031;
}

/* Battle Content */
.battle-content {
    padding: 25px;
    flex: 1;
}

.case-info,
.price-info,
.players-info {
    margin-bottom: 20px;
}

.label {
    color: var(--text-light);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.value {
    color: var(--text-dark);
    font-size: 18px;
    font-weight: 700;
}

.price {
    color: var(--success-color);
    font-size: 24px;
}

.players-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

.players-filled {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
}

.players-count {
    color: var(--text-light);
    font-size: 12px;
    font-weight: 600;
}

/* Battle Action */
.battle-action {
    padding: 0 25px 25px;
}

.battle-action form,
.battle-action a {
    width: 100%;
    display: block;
}

.btn-join,
.btn-view,
.btn-login,
.btn-disabled {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    text-align: center;
    text-decoration: none;
    display: block;
}

.btn-join {
    background: linear-gradient(135deg, var(--success-color), #00a378);
    color: white;
}

.btn-join:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 184, 148, 0.3);
}

.btn-view {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-view:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(108, 92, 231, 0.3);
}

.btn-login {
    background: var(--warning-color);
    color: var(--text-dark);
}

.btn-login:hover {
    background: #f8b900;
}

.btn-disabled {
    background: #e0e0e0;
    color: var(--text-light);
    cursor: not-allowed;
}

/* Price Summary */
.price-summary {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.05), rgba(162, 155, 254, 0.05));
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    margin: 20px 0;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    color: var(--text-dark);
    font-size: 15px;
}

.summary-item span:first-child {
    font-weight: 500;
}

.summary-item span:last-child {
    font-weight: 600;
    color: var(--primary-color);
}

.summary-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 10px 0;
}

.summary-item.total {
    padding-top: 15px;
    font-size: 16px;
}

.summary-item.total span:last-child {
    font-size: 20px;
    color: var(--success-color);
}

/* Balance Validation */
.balance-check {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 15px;
    font-weight: 600;
}

.balance-check .label {
    color: var(--text-dark);
}

.balance-check .amount {
    color: var(--primary-color);
    font-size: 18px;
}

.btn-primary:disabled,
.btn-primary.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #ccc;
}

.btn-primary:disabled:hover,
.btn-primary.disabled:hover {
    transform: none;
    box-shadow: none;
}

.total-cost {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #e0e0e0;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .battles-container {
        padding: 20px 15px;
    }

    .battles-header h1 {
        font-size: 36px;
    }

    .create-battle-section {
        grid-template-columns: 1fr;
    }

    .battles-grid {
        grid-template-columns: 1fr;
    }

    .battle-card {
        margin-bottom: 15px;
    }
}
