/**
 * Estilos Personalizados - Complemento de Bootstrap 5
 * Plataforma de Reservas de Pistas Deportivas
 */

/* ========================================
   Variables CSS
   ======================================== */
:root {
    --tennis-color: #16a34a;
    --padel-color: #2563eb;
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --mobile-nav-height: 60px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ========================================
   Tipografía y Base
   ======================================== */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ========================================
   Cards Mejoradas
   ======================================== */
.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 0.75rem;
}

.card-header {
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
}

/* Card header por defecto (sin clase de color) */
.card-header:not(.bg-primary):not(.bg-success):not(.bg-warning):not(.bg-danger):not(.bg-info):not(.bg-secondary):not(.bg-dark):not(.bg-light) {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

/* Asegurar que los colores de Bootstrap se apliquen en card-headers */
.card-header.bg-primary { background-color: #0d6efd !important; }
.card-header.bg-success { background-color: #198754 !important; }
.card-header.bg-warning { background-color: #ffc107 !important; }
.card-header.bg-danger { background-color: #dc3545 !important; }
.card-header.bg-info { background-color: #0dcaf0 !important; }
.card-header.bg-secondary { background-color: #6c757d !important; }
.card-header.bg-dark { background-color: #212529 !important; }
.card-header.text-white { color: #fff !important; }
.card-header.text-dark { color: #212529 !important; }

/* ========================================
   Stats Cards
   ======================================== */
.stat-card {
    background: #fff;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

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

.stat-icon.primary { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.stat-icon.success { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.stat-icon.warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.stat-icon.danger { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.stat-icon.info { background: rgba(6, 182, 212, 0.1); color: #06b6d4; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

/* ========================================
   Sport Cards (Selección de deporte)
   ======================================== */
.sport-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.sport-card {
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    color: inherit;
}

.sport-card:hover {
    border-color: #3b82f6;
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
}

.sport-card.active, .sport-card:focus {
    border-color: #3b82f6;
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
}

.sport-card.tennis.active {
    border-color: var(--tennis-color);
    background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%);
}

.sport-card.padel.active {
    border-color: var(--padel-color);
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
}

.sport-card i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.sport-card.tennis i { color: var(--tennis-color); }
.sport-card.padel i { color: var(--padel-color); }
.sport-card.gym i { color: #f59e0b; }

.sport-card.gym.active {
    border-color: #f59e0b;
    background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
}

.sport-card h4 {
    margin: 0;
    font-weight: 600;
}

/* ========================================
   Badges personalizados
   ======================================== */
.badge-tennis {
    background-color: var(--tennis-color) !important;
    color: #fff;
}

.badge-gym {
    background-color: #f59e0b !important;
    color: #fff;
}

.badge-padel {
    background-color: var(--padel-color) !important;
    color: #fff;
}

/* ========================================
   Slots de reserva
   ======================================== */
.slot-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.slot {
    min-width: 80px;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.slot-available {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.slot-available:hover {
    background: #bbf7d0;
    transform: scale(1.05);
}

.slot-occupied {
    background: #fee2e2;
    color: #991b1b;
    cursor: not-allowed;
    opacity: 0.7;
}

.slot-blocked {
    background: #fef3c7;
    color: #92400e;
    cursor: not-allowed;
    opacity: 0.8;
    position: relative;
}

.slot-blocked::before {
    content: '🚫';
    position: absolute;
    top: -2px;
    right: -2px;
    font-size: 0.6rem;
}

.slot-past {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}

.slot-selected {
    background: #3b82f6 !important;
    color: #fff !important;
    border-color: #1d4ed8 !important;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.4);
}

.slot-lighting::after {
    content: ' 💡';
}

/* ========================================
   Resumen de Reserva
   ======================================== */
.booking-summary {
    position: sticky;
    top: 100px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row.total {
    font-weight: 700;
    font-size: 1.125rem;
    padding-top: 1rem;
    margin-top: 0.5rem;
    border-top: 2px solid #e2e8f0;
    color: #3b82f6;
}

.summary-discount {
    color: #16a34a;
}

/* ========================================
   Monedero
   ======================================== */
.wallet-balance {
    background: var(--primary-gradient);
    color: white;
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.wallet-balance h4 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    opacity: 0.9;
}

.wallet-balance .amount {
    font-size: 2.5rem;
    font-weight: 700;
}

.movement-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.movement-item:last-child {
    border-bottom: none;
}

.movement-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.movement-icon.income {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.movement-icon.expense {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.movement-amount {
    font-weight: 700;
}

.movement-amount.income { color: #10b981; }
.movement-amount.expense { color: #ef4444; }

/* ========================================
   Grid de Ocupación
   ======================================== */
.occupancy-grid {
    display: grid;
    gap: 0;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    overflow: hidden;
    font-size: 0.875rem;
}

.occupancy-header {
    background: #1e293b;
    color: #fff;
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    border-right: 1px solid #334155;
}

.occupancy-header:last-child {
    border-right: none;
}

.occupancy-time {
    background: #f8fafc;
    padding: 0.5rem;
    text-align: center;
    font-weight: 500;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
}

.occupancy-cell {
    padding: 0.5rem;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.occupancy-cell:last-child {
    border-right: none;
}

.occupancy-cell.free {
    background: rgba(16, 185, 129, 0.1);
}

.occupancy-cell.booked {
    background: rgba(59, 130, 246, 0.15);
    color: #1d4ed8;
    font-size: 0.75rem;
}

.occupancy-cell.internal {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
    font-size: 0.75rem;
}

.occupancy-cell.blocked {
    background: rgba(239, 68, 68, 0.15);
    color: #b91c1c;
    font-size: 0.75rem;
}

.occupancy-bar {
    height: 24px;
    background: #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.occupancy-bar-fill {
    height: 100%;
    background: var(--success-gradient);
    transition: width 0.5s ease;
}

/* ========================================
   Tablas mejoradas
   ======================================== */
.table {
    margin-bottom: 0;
}

.table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
}

.table td {
    vertical-align: middle;
}

.table tbody tr:hover {
    background: #f8fafc;
}

/* ========================================
   Formularios mejorados
   ======================================== */
.form-control:focus, .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-label.required::after {
    content: ' *';
    color: #ef4444;
}

/* ========================================
   Botones mejorados
   ======================================== */
.btn {
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.4);
}

.btn-success {
    background: var(--success-gradient);
    border: none;
}

/* ========================================
   Loading Spinner
   ======================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Animaciones
   ======================================== */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   Navegación inferior móvil
   ======================================== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    z-index: 1050;
    padding-bottom: var(--safe-area-bottom);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.mobile-bottom-nav .nav {
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
}

.mobile-bottom-nav .nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #64748b;
    font-size: 0.7rem;
    padding: 0.5rem;
    text-decoration: none;
    transition: color 0.2s;
    min-width: 60px;
}

.mobile-bottom-nav .nav-link i {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.mobile-bottom-nav .nav-link.active {
    color: #3b82f6;
}

.mobile-bottom-nav .nav-link:hover {
    color: #3b82f6;
}

.mobile-bottom-nav .wallet-badge {
    position: absolute;
    top: 0;
    right: 50%;
    transform: translateX(80%);
    background: #10b981;
    color: #fff;
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    font-weight: 600;
}

/* ========================================
   Utilidades adicionales
   ======================================== */
.text-tennis { color: var(--tennis-color) !important; }
.text-padel { color: var(--padel-color) !important; }
.bg-tennis { background-color: var(--tennis-color) !important; }
.bg-padel { background-color: var(--padel-color) !important; }

.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }

.cursor-pointer { cursor: pointer; }
.shadow-hover:hover { box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); }

/* ========================================
   Búsqueda de usuarios (transferencias)
   ======================================== */
.search-result-item:hover {
    background-color: #f0f9ff;
}

#transfer-results {
    top: 100%;
    left: 0;
}

/* ========================================
   RESPONSIVE - TABLETS
   ======================================== */
@media (max-width: 991px) {
    .booking-summary {
        position: static;
        margin-top: 1.5rem;
    }
}

/* ========================================
   RESPONSIVE - MÓVILES
   ======================================== */
@media (max-width: 768px) {
    /* Mostrar navegación inferior */
    .mobile-bottom-nav {
        display: block;
    }
    
    /* Ajustar padding del body para la nav inferior */
    body {
        padding-bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 10px);
    }
    
    /* Ocultar elementos del navbar en móvil */
    .navbar .d-flex.align-items-center.gap-2 > .badge,
    .navbar .d-flex.align-items-center.gap-2 > .dropdown:last-child {
        display: none !important;
    }
    
    /* Container con menos padding */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    main.container {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
    
    /* Sport selector en una columna */
    .sport-selector {
        grid-template-columns: 1fr;
    }
    
    .sport-card {
        padding: 1.25rem;
    }
    
    .sport-card i {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }
    
    /* Stats más compactos */
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    /* Wallet balance */
    .wallet-balance {
        padding: 1.5rem;
        border-radius: 0.75rem;
    }
    
    .wallet-balance .amount {
        font-size: 2rem;
    }
    
    /* Slots más grandes para touch */
    .slot {
        min-width: 70px;
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .slot-container {
        gap: 0.4rem;
    }
    
    /* Cards sin bordes redondeados excesivos */
    .card {
        border-radius: 0.5rem;
    }
    
    /* Tablas scrolleables */
    .table-responsive {
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    .table th, .table td {
        white-space: nowrap;
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Hero section más compacto */
    .bg-primary.rounded-4.p-5 {
        padding: 1.5rem !important;
        border-radius: 0.75rem !important;
    }
    
    .bg-primary .display-5 {
        font-size: 1.5rem;
    }
    
    .bg-primary .lead {
        font-size: 0.9rem;
    }
    
    /* Botones en columna en móvil */
    .bg-primary .d-flex.gap-3 {
        flex-direction: column;
        gap: 0.75rem !important;
    }
    
    .bg-primary .btn-lg {
        width: 100%;
    }
    
    /* Ocultar columna decorativa */
    .bg-primary .col-lg-4 {
        display: none !important;
    }
    
    /* Formularios */
    .form-row {
        flex-direction: column;
    }
    
    .form-row .form-group {
        width: 100%;
    }
    
    /* Alerts más compactos */
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Movimientos del monedero */
    .movement-item {
        padding: 0.75rem;
    }
    
    .movement-icon {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    /* Reserva summary */
    .booking-summary .card-body {
        padding: 1rem;
    }
    
    .summary-row {
        padding: 0.5rem 0;
        font-size: 0.9rem;
    }
    
    /* Títulos */
    h2 {
        font-size: 1.5rem;
    }
    
    h5.card-title, .card-header h5 {
        font-size: 1rem;
    }
    
    /* Login/Registro centrado */
    .row.justify-content-center .col-md-5 {
        max-width: 100%;
    }
    
    /* Dropdown menus */
    .dropdown-menu {
        font-size: 0.9rem;
    }
    
    /* Footer compacto */
    footer .container .row {
        text-align: center;
    }
    
    footer .col-md-6.text-md-end {
        text-align: center !important;
        margin-top: 1rem;
    }
}

/* ========================================
   RESPONSIVE - MÓVILES PEQUEÑOS
   ======================================== */
@media (max-width: 375px) {
    .stat-card {
        flex-direction: column;
        text-align: center;
    }
    
    .slot {
        min-width: 60px;
        padding: 0.6rem 0.3rem;
        font-size: 0.75rem;
    }
    
    .navbar-brand span {
        font-size: 0.9rem;
    }
    
    .mobile-bottom-nav .nav-link {
        font-size: 0.65rem;
        min-width: 50px;
    }
    
    .mobile-bottom-nav .nav-link i {
        font-size: 1.1rem;
    }
}

/* ========================================
   PWA / Pantalla completa
   ======================================== */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top, 0px);
    }
    
    .navbar {
        padding-top: env(safe-area-inset-top, 0px);
    }
}

/* ========================================
   Iconos de Deportes Personalizados
   ======================================== */
.sport-icon-tennis,
.sport-icon-padel,
.sport-icon-gym {
    display: inline-block;
    width: 1.2em;
    height: 1.2em;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    vertical-align: middle;
}

.sport-icon-tennis {
    background-image: url('../img/icon-tennis.svg');
}

.sport-icon-padel {
    background-image: url('../img/icon-padel.svg');
}

/* Tamaños */
.sport-icon-sm { width: 1em; height: 1em; }
.sport-icon-md { width: 1.5em; height: 1.5em; }
.sport-icon-lg { width: 2em; height: 2em; }
.sport-icon-xl { width: 3em; height: 3em; }
.sport-icon-xxl { width: 5em; height: 5em; }

/* Filtros de color para iconos (negro por defecto) */
.sport-icon-white {
    filter: brightness(0) invert(1);
}

.sport-icon-green {
    filter: brightness(0) saturate(100%) invert(50%) sepia(98%) saturate(436%) hue-rotate(88deg) brightness(93%) contrast(88%);
}

.sport-icon-blue {
    filter: brightness(0) saturate(100%) invert(32%) sepia(98%) saturate(1234%) hue-rotate(213deg) brightness(97%) contrast(93%);
}