/* ============================================
   JAÉN SPORTS — Extended Components
   Modals, Chat, Toasts, Calendar, Tabs, etc.
   ============================================ */

/* ========== MODAL ========== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 22, 40, 0.6);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn var(--transition-fast);
}

.modal {
    background: var(--color-white);
    border-radius: var(--radius-2xl);
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: scaleIn var(--transition-base);
    box-shadow: var(--shadow-2xl);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-6);
    border-bottom: 1px solid var(--color-gray-100);
}

.modal-header h3 {
    font-size: var(--text-xl);
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--color-gray-400);
    transition: background var(--transition-fast);
}

.modal-close:hover {
    background: var(--color-gray-100);
    color: var(--color-gray-700);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-6);
    border-top: 1px solid var(--color-gray-100);
}

/* ========== TOASTS ========== */
.toast-container {
    position: fixed;
    top: 88px;
    right: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    z-index: var(--z-toast);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    animation: slideInRight 0.4s ease forwards;
    pointer-events: auto;
    border-left: 4px solid;
}

.toast.success {
    border-left-color: var(--color-success);
}

.toast.warning {
    border-left-color: var(--color-warning);
}

.toast.error {
    border-left-color: var(--color-error);
}

.toast.info {
    border-left-color: var(--color-info);
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast.success .toast-icon {
    color: var(--color-success);
}

.toast.warning .toast-icon {
    color: var(--color-warning);
}

.toast.error .toast-icon {
    color: var(--color-error);
}

.toast.info .toast-icon {
    color: var(--color-info);
}

.toast-content h5 {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-gray-900);
    margin-bottom: 2px;
}

.toast-content p {
    font-size: var(--text-xs);
    color: var(--color-gray-500);
}

.toast-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--color-gray-400);
    margin-left: auto;
    flex-shrink: 0;
}

.toast-close:hover {
    background: var(--color-gray-100);
}

.toast.hiding {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ========== BADGE ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
}

.badge-primary {
    background: var(--color-primary-100);
    color: var(--color-primary-700);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--color-warning);
}

.badge-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-error);
}

/* ========== TABS ========== */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--color-gray-200);
    gap: 0;
    overflow-x: auto;
}

.tab {
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
    white-space: nowrap;
    cursor: pointer;
}

.tab:hover {
    color: var(--color-gray-700);
}

.tab.active {
    color: var(--color-primary-500);
    border-bottom-color: var(--color-primary-500);
}

.tab-content {
    display: none;
    padding: var(--space-6) 0;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

/* ========== AVATAR ========== */
.avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
    background: var(--color-primary-100);
    color: var(--color-primary-600);
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: var(--text-xs);
}

.avatar-lg {
    width: 64px;
    height: 64px;
    font-size: var(--text-xl);
}

.avatar-xl {
    width: 96px;
    height: 96px;
    font-size: var(--text-3xl);
}

/* ========== CHAT ========== */
.chat-panel {
    position: fixed;
    bottom: 90px;
    right: var(--space-6);
    width: 380px;
    max-height: 520px;
    background: var(--color-white);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    z-index: var(--z-chat);
    display: none;
    flex-direction: column;
    animation: scaleIn var(--transition-base);
    border: 1px solid var(--color-gray-200);
}

.chat-panel.open {
    display: flex;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-gray-100);
    background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-700));
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    color: var(--color-white);
}

.chat-header h4 {
    color: var(--color-white);
    font-size: var(--text-sm);
}

.chat-header p {
    font-size: var(--text-xs);
    color: rgba(255, 255, 255, 0.7);
}

.chat-status {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--color-accent-light);
    animation: pulse 2s infinite;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-height: 360px;
}

.chat-bubble {
    max-width: 85%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-xl);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    animation: fadeIn 0.3s ease;
}

.chat-bubble.bot {
    background: var(--color-gray-100);
    color: var(--color-gray-800);
    align-self: flex-start;
    border-bottom-left-radius: var(--radius-sm);
}

.chat-bubble.user {
    background: var(--color-primary-500);
    color: var(--color-white);
    align-self: flex-end;
    border-bottom-right-radius: var(--radius-sm);
}

.chat-input-area {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--color-gray-100);
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    outline: none;
    transition: border-color var(--transition-fast);
}

.chat-input:focus {
    border-color: var(--color-primary-400);
}

.chat-send {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--color-primary-500);
    color: var(--color-white);
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.chat-send:hover {
    background: var(--color-primary-600);
    transform: scale(1.05);
}

.chat-send svg {
    width: 18px;
    height: 18px;
}

.chat-fab {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-700));
    color: var(--color-white);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(26, 86, 219, 0.4);
    z-index: var(--z-chat);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    cursor: pointer;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(26, 86, 219, 0.5);
}

.chat-fab svg {
    width: 26px;
    height: 26px;
}

.chat-fab .notification-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    background: var(--color-error);
    border-radius: var(--radius-full);
    border: 2px solid var(--color-white);
}

/* ========== NOTIFICATION CENTER ========== */
.notification-bell {
    position: relative;
    width: 40px;
    height: 40px;
    display: none !important;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
    color: var(--color-gray-600);
}

.notification-bell:hover {
    background: var(--color-gray-100);
}

.notification-bell svg {
    width: 20px;
    height: 20px;
}

.notification-count {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--color-error);
    color: var(--color-white);
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: var(--weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--color-white);
}

.notification-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-height: 420px;
    background: var(--color-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-gray-200);
    overflow: hidden;
    display: none;
    z-index: var(--z-dropdown);
}

.notification-dropdown.open {
    display: block;
    animation: fadeInDown 0.2s ease;
}

.notification-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-gray-100);
}

.notification-dropdown-header h4 {
    font-size: var(--text-sm);
}

.notification-list {
    max-height: 340px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-gray-50);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.notification-item:hover {
    background: var(--color-gray-50);
}

.notification-item.unread {
    background: var(--color-primary-50);
}

.notification-item-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--color-primary-100);
    color: var(--color-primary-500);
    flex-shrink: 0;
}

.notification-item-icon svg {
    width: 16px;
    height: 16px;
}

.notification-item-content h5 {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    margin-bottom: 2px;
}

.notification-item-content p {
    font-size: var(--text-xs);
    color: var(--color-gray-500);
}

/* ========== CALENDAR ========== */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--color-gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.calendar-day-header {
    padding: var(--space-3);
    text-align: center;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--color-gray-500);
    text-transform: uppercase;
    background: var(--color-gray-50);
}

.calendar-day {
    min-height: 80px;
    padding: var(--space-2);
    background: var(--color-white);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.calendar-day:hover {
    background: var(--color-primary-50);
}

.calendar-day.today {
    background: var(--color-primary-50);
}

.calendar-day.other-month {
    opacity: 0.4;
}

.calendar-day-number {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    margin-bottom: var(--space-1);
}

.today .calendar-day-number {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-500);
    color: var(--color-white);
    border-radius: var(--radius-full);
}

.calendar-event {
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: var(--weight-medium);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-event.futsal {
    background: rgba(26, 86, 219, 0.15);
    color: var(--color-futsal);
}

.calendar-event.futbol11 {
    background: rgba(5, 150, 105, 0.15);
    color: var(--color-futbol11);
}

.calendar-event.padel {
    background: rgba(124, 58, 237, 0.15);
    color: var(--color-padel);
}

/* ========== STEPS ========== */
.steps {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: var(--space-8);
}

.step {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
    position: relative;
}

.step:not(:last-child)::after {
    content: '';
    flex: 1;
    height: 2px;
    background: var(--color-gray-200);
    margin: 0 var(--space-3);
}

.step.completed::after {
    background: var(--color-primary-500);
}

.step-number {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--color-gray-200);
    color: var(--color-gray-500);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    flex-shrink: 0;
    transition: all var(--transition-base);
}

.step.active .step-number {
    background: var(--color-primary-500);
    color: var(--color-white);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.step.completed .step-number {
    background: var(--color-primary-500);
    color: var(--color-white);
}

.step-label {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-gray-500);
    white-space: nowrap;
}

.step.active .step-label {
    color: var(--color-primary-500);
}

.step.completed .step-label {
    color: var(--color-gray-700);
}

/* ========== FAQ ========== */
.faq-item {
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
    overflow: hidden;
    transition: border-color var(--transition-fast);
}

.faq-item:hover {
    border-color: var(--color-primary-200);
}

.faq-question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-5) var(--space-6);
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    color: var(--color-gray-800);
    cursor: pointer;
    text-align: left;
    background: transparent;
    transition: background var(--transition-fast);
}

.faq-question:hover {
    background: var(--color-gray-50);
}

.faq-question svg {
    width: 20px;
    height: 20px;
    color: var(--color-gray-400);
    flex-shrink: 0;
    transition: transform var(--transition-base);
}

.faq-item.open .faq-question svg {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.3s ease;
}

.faq-item.open .faq-answer {
    max-height: 500px;
    padding: 0 var(--space-6) var(--space-5);
}

.faq-answer p {
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
}

/* ========== STAT ========== */
.stat-card {
    text-align: center;
    padding: var(--space-6);
}

.stat-value {
    font-family: var(--font-heading);
    font-size: var(--text-4xl);
    font-weight: var(--weight-extrabold);
    color: var(--color-primary-500);
    line-height: 1;
    margin-bottom: var(--space-2);
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--color-gray-500);
    font-weight: var(--weight-medium);
}

/* ========== SKELETON ========== */
.skeleton {
    background: linear-gradient(90deg, var(--color-gray-200) 25%, var(--color-gray-100) 50%, var(--color-gray-200) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 14px;
    margin-bottom: var(--space-2);
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--space-3);
}

.skeleton-img {
    height: 200px;
    border-radius: var(--radius-xl);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .chat-panel {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    }

    .toast-container {
        right: var(--space-4);
        left: var(--space-4);
    }

    .toast {
        max-width: 100%;
    }

    .notification-dropdown {
        right: -60px;
        width: calc(100vw - 40px);
    }

    .steps {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-4);
    }

    .step::after {
        display: none;
    }

    .modal {
        margin: var(--space-4);
        max-height: calc(100vh - 40px);
    }

    .calendar-day {
        min-height: 50px;
    }

    .calendar-event {
        font-size: 9px;
        padding: 1px 4px;
    }
}