/* Weekly Plan Dashboard Styles */

.training-dashboard {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin: 10px 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: calc(100vh - 150px);
    overflow: hidden;
}

.dashboard-title {
    text-align: center;
    margin-bottom: 12px;
}

.dashboard-title h4 {
    color: #1e40af;
    font-size: 1.2rem;
    margin: 0;
}

.training-chart {
    background: #ffffff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    max-height: calc(100vh - 250px);
    overflow: hidden;
}

.chart-container {
    max-width: 100%;
    overflow-x: auto;
}

.training-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    table-layout: fixed;
}

.training-table th {
    background: linear-gradient(135deg, #ffe566 0%, #e6be18 100%);
    color: #1e293b;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 10px 6px;
    text-align: center;
    border: 1px solid #1e40af;
}

.training-table th:first-child {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    text-align: left;
    padding-left: 12px;
    width: 100px;
}

.training-table td {
    padding: 0;
    border: 1px solid #e5e7eb;
    text-align: center;
    vertical-align: middle;
    position: relative;
}

.training-table tr:nth-child(even) {
    background-color: #f9fafb;
}

.training-table tr:hover {
    background-color: #f3f4f6;
}

.category-cell {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 10px 12px;
    font-weight: 600;
    font-size: 0.8rem;
    color: #374151;
    text-align: left;
    border-right: 2px solid #cbd5e1;
}

.category-icon {
    font-size: 1rem;
    margin-right: 6px;
    display: inline-block;
    width: 18px;
    text-align: center;
}

.training-cell {
    width: 70px;
    height: 50px;
    border: 1px solid #d1d5db;
    background: white;
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
}

.training-cell:hover {
    background: #f8fafc;
    border-color: #ffe566;
    transform: scale(1.02);
}

.training-cell.has-training {
    border-color: #ffe566;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    box-shadow: 0 2px 4px rgba(255, 229, 102, 0.2);
}

.training-cell.has-training::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 4px;
}

.training-cell-content {
    position: relative;
    z-index: 1;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: #1e40af;
    padding: 3px;
    line-height: 1.2;
}

.training-cell.has-training.long-run {
    border-color: #f59e0b;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.training-cell.has-training.long-run::before {
    background: rgba(245, 158, 11, 0.1);
}

.training-cell.has-training.long-run .training-cell-content {
    color: #92400e;
}

.training-cell.has-training.easy-run {
    border-color: #10b981;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
}

.training-cell.has-training.easy-run::before {
    background: rgba(16, 185, 129, 0.1);
}

.training-cell.has-training.easy-run .training-cell-content {
    color: #065f46;
}

.training-cell.has-training.intervals {
    border-color: #ef4444;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
}

.training-cell.has-training.intervals::before {
    background: rgba(239, 68, 68, 0.1);
}

.training-cell.has-training.intervals .training-cell-content {
    color: #991b1b;
}

.training-cell.has-training.strength {
    border-color: #8b5cf6;
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
}

.training-cell.has-training.strength::before {
    background: rgba(139, 92, 246, 0.1);
}

.training-cell.has-training.strength .training-cell-content {
    color: #5b21b6;
}

.training-cell.has-training.rest {
    border-color: #6b7280;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.training-cell.has-training.rest::before {
    background: rgba(107, 114, 128, 0.1);
}

.training-cell.has-training.rest .training-cell-content {
    color: #374151;
}

.dashboard-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.btn-introduce-plan {
    background: linear-gradient(135deg, #ffe566 0%, #e6be18 100%);
    color: #1e293b;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.btn-introduce-plan:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(59, 130, 246, 0.4);
}

.btn-generate-plan {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(139, 92, 246, 0.3);
}

.btn-generate-plan:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(139, 92, 246, 0.4);
}

/* Nutrition Plan Button Container */
.nutrition-plan-button-container {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    width: 100%;
}

.btn-view-nutrition-plan {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    justify-content: center;
}

.btn-view-nutrition-plan:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.btn-view-nutrition-plan:disabled {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    cursor: not-allowed;
    opacity: 0.7;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-view-nutrition-plan:disabled:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-view-nutrition-plan .btn-icon {
    font-size: 1.2rem;
    display: inline-block;
}

.nutrition-plan-warning {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: #6b7280;
    font-style: italic;
    display: none;
}

.nutrition-plan-warning.show {
    display: block;
}

/* Plan Form Styles */
.plan-form-container {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin: 10px 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.plan-form {
    max-width: 800px;
    margin: 0 auto;
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
}

.form-header h4 {
    color: #1e40af;
    font-size: 1.2rem;
    margin: 0;
}

.btn-close-form {
    background: #ef4444;
    color: #1e293b;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-close-form:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.day-planning {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.day-section {
    background: #f8fafc;
    border-radius: 6px;
    padding: 12px;
    border: 2px solid #e5e7eb;
    transition: all 0.2s ease;
}

.day-section:hover {
    border-color: #ffe566;
    box-shadow: 0 2px 8px rgba(255, 229, 102, 0.1);
}

.day-section h5 {
    color: #374151;
    font-size: 1rem;
    margin: 0 0 8px 0;
    font-weight: 600;
}

.day-inputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.training-type {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.85rem;
    background: white;
    transition: all 0.2s ease;
}

.training-type:focus {
    outline: none;
    border-color: #ffe566;
    box-shadow: 0 0 0 3px rgba(255, 229, 102, 0.1);
}

.training-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-input {
    width: 100%;
    padding: 6px 8px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.8rem;
    background: white;
    transition: all 0.2s ease;
}

.detail-input:focus {
    outline: none;
    border-color: #ffe566;
    box-shadow: 0 0 0 3px rgba(255, 229, 102, 0.1);
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding-top: 12px;
    border-top: 2px solid #e5e7eb;
}

.btn-save-plan {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #1e293b;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.btn-save-plan:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.4);
}

.btn-cancel-plan {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: #1e293b;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(107, 114, 128, 0.3);
}

.btn-cancel-plan:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(107, 114, 128, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    .training-table th {
        font-size: 0.8rem;
        padding: 8px 4px;
    }
    
    .training-table th:first-child {
        min-width: 100px;
        padding-left: 12px;
    }
    
    .category-cell {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .category-icon {
        font-size: 1rem;
        width: 16px;
    }
    
    .training-cell {
        width: 60px;
        height: 50px;
    }
    
    .training-cell-content {
        font-size: 0.7rem;
        padding: 2px;
    }
    
    .day-planning {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .training-dashboard,
    .plan-form-container {
        padding: 12px;
        margin: 8px 0;
    }
    
    .training-chart {
        padding: 12px;
    }
    
    .training-table th {
        font-size: 0.75rem;
        padding: 6px 2px;
    }
    
    .training-table th:first-child {
        min-width: 80px;
        padding-left: 8px;
    }
    
    .category-cell {
        padding: 6px 8px;
        font-size: 0.75rem;
    }
    
    .category-icon {
        font-size: 0.9rem;
        width: 14px;
    }
    
    .training-cell {
        width: 50px;
        height: 40px;
    }
    
    .training-cell-content {
        font-size: 0.65rem;
        padding: 1px;
    }
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ========================================
   VISTA DE TARJETAS EN MÓVIL
   ======================================== */

@media (max-width: 768px) {
    /* Ocultar tabla en móvil */
    .training-table,
    .chart-container {
        display: none !important;
    }
    
    /* Mostrar vista de texto en móvil */
    #mobilePlanView {
        display: block !important;
        padding: 1rem;
        background: white;
        border-radius: 12px;
        margin-bottom: 1rem;
        max-height: 400px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: #ffd31b #f1f5f9;
    }
    
    #mobilePlanView::-webkit-scrollbar {
        width: 6px;
    }
    
    #mobilePlanView::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 3px;
    }
    
    #mobilePlanView::-webkit-scrollbar-thumb {
        background: #ffd31b;
        border-radius: 3px;
    }
    
    /* Asegurar que el contenedor de la tabla no tenga max-height */
    .training-chart {
        max-height: none !important;
        overflow: visible !important;
    }
    
    .training-dashboard {
        max-height: none !important;
        overflow: visible !important;
    }
    
    /* Asegurar que los botones sean visibles */
    .dashboard-actions {
        position: relative;
        z-index: 100;
        padding-top: 1rem;
    }
    
    .btn-introduce-plan,
    .btn-generate-plan {
        width: 100%;
        min-height: 48px;
        font-size: 1rem;
        touch-action: manipulation;
    }
    
    /* Hacer que los elementos de la vista móvil sean claramente clicables */
    #mobilePlanView > div {
        cursor: pointer;
        user-select: none;
        -webkit-tap-highlight-color: rgba(255, 211, 27, 0.3);
        touch-action: manipulation;
    }
    
    #mobilePlanView > div:active {
        transform: scale(0.98);
        background-color: #e2e8f0 !important;
    }
    
    /* Ajustar el modal para móvil */
    .weekly-plan-modal-content {
        max-width: 100%;
        max-height: 95vh;
        margin: 0;
        border-radius: 16px 16px 0 0;
    }
    
    .weekly-plan-modal-body {
        padding: 1rem;
        max-height: calc(95vh - 120px);
        overflow-y: auto;
    }
}

@media (min-width: 769px) {
    /* Ocultar vista móvil en desktop */
    #mobilePlanView {
        display: none !important;
    }
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

/* ========================================
   TABLAS RESPONSIVE MEJORADAS
   ======================================== */

/* Contenedor de tabla con scroll horizontal en móvil */
.chart-container,
.training-chart {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #ffd31b #f1f5f9;
}

.chart-container::-webkit-scrollbar,
.training-chart::-webkit-scrollbar {
    height: 8px;
}

.chart-container::-webkit-scrollbar-track,
.training-chart::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.chart-container::-webkit-scrollbar-thumb,
.training-chart::-webkit-scrollbar-thumb {
    background: #ffd31b;
    border-radius: 4px;
}

/* Tabla con ancho mínimo en móvil */
.training-table {
    min-width: 100%;
}

@media (max-width: 768px) {
    .training-table {
        min-width: 700px;
        font-size: 0.85rem;
    }
    
    .training-table th {
        padding: 10px 6px;
        font-size: 0.8rem;
    }
    
    .training-table th:first-child {
        min-width: 100px;
        padding-left: 8px;
    }
    
    .training-cell {
        width: 70px;
        height: 55px;
        min-height: 55px;
    }
    
    .category-cell {
        font-size: 0.75rem;
        padding: 8px 10px;
        white-space: nowrap;
    }
    
    /* Ocultar indicador después de 5 segundos */
    .training-chart::after {
        animation: fadeInOut 3s infinite 0s;
    }
}

@media (max-width: 480px) {
    .training-table {
        min-width: 600px;
        font-size: 0.75rem;
    }
    
    .training-table th {
        padding: 8px 4px;
        font-size: 0.7rem;
    }
    
    .training-cell {
        width: 60px;
        height: 50px;
        min-height: 50px;
    }
    
    .training-cell-content {
        font-size: 0.65rem;
        padding: 2px;
    }
    
    .category-cell {
        font-size: 0.7rem;
        padding: 6px 8px;
    }
    
    /* Indicador más visible en móviles pequeños */
    .training-chart::after {
        font-size: 0.65rem;
        padding: 3px 6px;
        top: 5px;
        right: 5px;
    }
}

/* Botones de acción siempre visibles */
.btn-introduce-plan,
.btn-generate-plan,
.btn-save-plan,
.btn-cancel-plan {
    min-height: 44px;
    min-width: 120px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 211, 27, 0.3);
}

@media (max-width: 480px) {
    .btn-introduce-plan,
    .btn-generate-plan,
    .btn-save-plan,
    .btn-cancel-plan {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Weekly Plan Modal Styles */
.weekly-plan-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 1rem;
}

.weekly-plan-modal-content {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.weekly-plan-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #ffe566 0%, #e6be18 100%);
}

.weekly-plan-modal-header h3 {
    margin: 0;
    color: #1e293b;
    font-size: 1.5rem;
    font-weight: 600;
}

.weekly-plan-modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #1e293b;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.weekly-plan-modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

.weekly-plan-modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.weekly-plan-modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    background: #f8fafc;
}

.weekly-plan-question {
    margin-bottom: 2rem;
}

.weekly-plan-question h4 {
    margin: 0 0 1rem 0;
    color: #1e293b;
    font-size: 1.25rem;
    font-weight: 600;
}

.weekly-plan-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.weekly-plan-option {
    padding: 1rem 1.5rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-weight: 500;
    color: #1e293b;
}

.weekly-plan-option:hover {
    border-color: #ffd31b;
    background: #fffbeb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 211, 27, 0.2);
}

.weekly-plan-option.selected {
    border-color: #ffd31b;
    background: #fffbeb;
    box-shadow: 0 4px 12px rgba(255, 211, 27, 0.3);
}

.weekly-plan-training-type-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 1rem;
    background: white;
    color: #1e293b;
}

.weekly-plan-training-type-select:focus {
    outline: none;
    border-color: #ffd31b;
}

.weekly-plan-training-details {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
}

.weekly-plan-detail-group {
    margin-bottom: 1rem;
}

.weekly-plan-detail-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #374151;
    font-weight: 500;
    font-size: 0.9rem;
}

.weekly-plan-detail-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    color: #1e293b;
}

.weekly-plan-detail-group input:focus {
    outline: none;
    border-color: #ffd31b;
}

.weekly-plan-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.weekly-plan-btn-primary {
    background: linear-gradient(135deg, #ffe566 0%, #e6be18 100%);
    color: #1e293b;
}

.weekly-plan-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 211, 27, 0.3);
}

.weekly-plan-btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.weekly-plan-btn-secondary:hover {
    background: #d1d5db;
}

.weekly-plan-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .weekly-plan-modal-content {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .weekly-plan-modal-body {
        padding: 1.5rem;
    }
    
    .weekly-plan-options {
        gap: 0.75rem;
    }
    
    .weekly-plan-option {
        padding: 0.875rem 1.25rem;
    }
}
