/* =========================================
   GESTION ENTRENAMIENTOS - Estilos
   ========================================= */

:root {
    --primary-blue: #4a7ba7;
    --secondary-blue: #5b8fb9;
}

/* HEADER */
.header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    padding: clamp(16px, 4vw, 20px);
    padding-top: calc(clamp(16px, 4vw, 20px) + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.logo {
    height: clamp(35px, 8vw, 45px);
    width: auto;
}

.header-title {
    font-size: clamp(18px, 4.5vw, 22px);
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
}

.back-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.back-btn svg {
    width: 20px;
    height: 20px;
}

/* CONTENT */
.content {
    padding: clamp(16px, 4vw, 24px);
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
    max-width: 600px;
    margin: 0 auto;
}

/* ALERTS */
.alert-success {
    position: fixed !important;
    top: 80px !important;
    left: 50% !important;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 14px 24px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 14px;
    z-index: 9998 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    animation: slideDownFade 0.3s ease-out;
    transition: all 0.3s ease;
}

.alert-success svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDownFade {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* INFO CARD */
.info-card {
    background: white;
    border-radius: clamp(16px, 4vw, 20px);
    padding: clamp(18px, 4.5vw, 24px);
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(74, 123, 167, 0.1);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    animation: slideUp 0.4s ease-out;
}

.info-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.info-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.info-text h2 {
    font-size: clamp(16px, 4vw, 18px);
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
}

.info-text p {
    font-size: clamp(13px, 3.2vw, 14px);
    color: #666;
    line-height: 1.5;
}

/* SEARCH CARD */
.search-card {
    background: white;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(74, 123, 167, 0.1);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    border-radius: 10px;
    padding: 12px 16px;
}

.search-box svg {
    width: 20px;
    height: 20px;
    color: #9ca3af;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 15px;
    color: #333;
    outline: none;
}

.search-input::placeholder {
    color: #9ca3af;
}

/* SECTION TITLE */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    padding: 14px 16px;
    border-radius: 12px;
}

.section-title {
    font-size: clamp(15px, 3.8vw, 17px);
    font-weight: 700;
    color: white;
    margin: 0;
}

.btn-add {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-add:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-add svg {
    width: 18px;
    height: 18px;
}

/* STUDENTS LIST */
.students-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.student-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(74, 123, 167, 0.1);
    transition: all 0.3s ease;
    animation: slideUp 0.4s ease-out backwards;
}

.student-card:nth-child(1) { animation-delay: 0.05s; }
.student-card:nth-child(2) { animation-delay: 0.1s; }
.student-card:nth-child(3) { animation-delay: 0.15s; }
.student-card:nth-child(4) { animation-delay: 0.2s; }

.student-card:hover {
    transform: translateX(8px);
    box-shadow: 0 8px 25px rgba(74, 123, 167, 0.2);
}

.student-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.student-avatar svg {
    width: 24px;
    height: 24px;
    color: white;
}

.student-info {
    flex: 1;
    min-width: 0;
}

.student-name {
    font-weight: 600;
    color: #333;
    font-size: 15px;
    margin-bottom: 2px;
}

.student-rut {
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
}

.student-stats {
    display: flex;
    gap: 12px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #666;
}

.stat svg {
    width: 14px;
    height: 14px;
    color: var(--primary-blue);
}

.stat.new-student {
    color: #f59e0b;
}

.stat.new-student svg {
    color: #f59e0b;
}

.arrow {
    width: 20px;
    height: 20px;
    color: #ccc;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.student-card:hover .arrow {
    color: var(--primary-blue);
    transform: translateX(4px);
}

/* STUDENT DETAIL CARD */
.student-detail-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(74, 123, 167, 0.1);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.student-avatar-large {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.student-avatar-large svg {
    width: 32px;
    height: 32px;
    color: white;
}

.student-detail-info {
    flex: 1;
    min-width: 120px;
}

.student-detail-name {
    font-weight: 700;
    color: #333;
    font-size: 18px;
    margin-bottom: 4px;
}

.student-detail-rut {
    font-size: 14px;
    color: #666;
}

.btn-add-exercise {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-add-exercise:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

.btn-add-exercise svg {
    width: 18px;
    height: 18px;
}

/* DAYS TABS */
.days-tabs {
    display: flex;
    background: white;
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
}

.day-tab {
    flex: 1;
    min-width: 45px;
    padding: 10px 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    background: none;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.day-tab.active {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    color: white;
}

.day-tab:not(.active):hover {
    background: #f3f4f6;
}

/* DAY CONTENT */
.day-content {
    display: none;
}

.day-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* EXERCISE CARD */
.exercise-card {
    background: white;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 4px 15px rgba(74, 123, 167, 0.1);
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

/* Ejercicios de plantilla tienen borde violeta */
.exercise-card.from-plantilla {
    border-left: 4px solid #8b5cf6;
    background: linear-gradient(to right, #faf5ff, white);
}

/* Ejercicios de grupo tienen borde naranja */
.exercise-card.from-grupo {
    border-left: 4px solid #f59e0b;
    background: linear-gradient(to right, #fffbeb, white);
}

/* Origin Tag inline con el nombre */
.origen-tag {
    display: inline-block;
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    text-transform: uppercase;
    vertical-align: middle;
}

.origen-tag.plantilla {
    background: #ede9fe;
    color: #7c3aed;
}

.origen-tag.grupo {
    background: #fef3c7;
    color: #d97706;
}

/* Exercise content wrapper */
.exercise-content {
    flex: 1;
    min-width: 0;
}

.exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.exercise-name {
    font-weight: 700;
    color: #333;
    font-size: 16px;
    margin-bottom: 2px;
}

.exercise-muscle {
    font-size: 13px;
    color: var(--primary-blue);
    font-weight: 500;
}

.btn-delete {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #fee2e2;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-delete:hover {
    background: #fecaca;
}

.btn-delete svg {
    width: 18px;
    height: 18px;
    color: #dc2626;
}

.exercise-details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.detail {
    text-align: center;
    background: #f8fafc;
    padding: 10px 8px;
    border-radius: 10px;
}

.detail-label {
    font-size: 11px;
    color: #666;
    display: block;
    margin-bottom: 2px;
}

.detail-value {
    font-size: 15px;
    font-weight: 700;
    color: #333;
}

.exercise-notes {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: #fef3c7;
    border-radius: 8px;
    font-size: 13px;
    color: #92400e;
}

.exercise-notes svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* EMPTY DAY */
.empty-day, .rest-day {
    background: white;
    border-radius: 14px;
    padding: 40px 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(74, 123, 167, 0.1);
}

.empty-day svg, .rest-day svg {
    width: 48px;
    height: 48px;
    color: #d1d5db;
    margin-bottom: 12px;
}

.empty-day p, .rest-day p {
    color: #666;
    font-size: 14px;
    margin-bottom: 16px;
}

.rest-day {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.rest-day svg {
    color: var(--primary-blue);
}

.btn-add-small {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-add-small:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 123, 167, 0.3);
}

/* MODAL */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9999 !important;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 24px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    transform: scale(0.9);
    transition: all 0.3s ease;
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

.modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #fee2e2;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-icon svg {
    width: 32px;
    height: 32px;
    color: #dc2626;
}

.modal-icon.warning {
    background: #fef3c7;
}

.modal-icon.warning svg {
    color: #d97706;
}

.modal-content h3 {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.modal-content p {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
}

.btn-cancel-modal {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    background: #f3f4f6;
    border: none;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-cancel-modal:hover {
    background: #e5e7eb;
}

.btn-confirm-delete {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: none;
    font-size: 14px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-confirm-delete:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

/* FORM CARD */
.form-card {
    background: white;
    border-radius: clamp(16px, 4vw, 20px);
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: 0 4px 15px rgba(74, 123, 167, 0.1);
}

.form-header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-weight: 600;
    font-size: 15px;
}

.form-header svg {
    width: 20px;
    height: 20px;
}

.form-body {
    padding: 16px;
}

/* SEARCH BOX SMALL */
.search-box-small {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
}

.search-box-small svg {
    width: 18px;
    height: 18px;
    color: #9ca3af;
}

/* EXERCISE SELECT LIST */
.exercise-select-list {
    max-height: 280px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.exercise-select-item input {
    display: none;
}

.exercise-select-card {
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.exercise-select-item input:checked + .exercise-select-card {
    border-color: var(--primary-blue);
    background: rgba(74, 123, 167, 0.05);
}

.exercise-select-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    margin-bottom: 2px;
}

.exercise-select-muscle {
    font-size: 12px;
    color: #666;
}

/* DAY SELECT GRID */
.day-select-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.day-select-item input {
    display: none;
}

.day-select-btn {
    display: block;
    padding: 10px 6px;
    text-align: center;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
}

.day-select-item input:checked + .day-select-btn {
    border-color: var(--primary-blue);
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    color: white;
}

/* CONFIG GRID */
.config-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.config-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 6px;
}

.config-field input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    text-align: center;
    transition: all 0.3s ease;
}

.config-field input:focus {
    outline: none;
    border-color: var(--primary-blue);
}

/* NOTES FIELD */
.notes-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 6px;
}

.notes-field textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    color: #333;
    resize: vertical;
    font-family: inherit;
    transition: all 0.3s ease;
}

.notes-field textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
}

/* SUBMIT BUTTON */
.btn-submit-full {
    width: 100%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
}

.btn-submit-full:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

.btn-submit-full svg {
    width: 20px;
    height: 20px;
}

/* RESPONSIVE */
@media (max-width: 360px) {
    .exercise-details {
        grid-template-columns: repeat(2, 1fr);
    }

    .day-select-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .config-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) {
    .content {
        padding: 32px;
    }

    .students-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .student-card:hover {
        transform: translateY(-4px);
    }
}

/* =========================================
   DRAG & DROP STYLES
   ========================================= */

/* Section title with drag hint */
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.drag-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 10px;
    border-radius: 20px;
}

.drag-hint svg {
    opacity: 0.8;
}

/* Exercise card with drag handle */
.exercise-card {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    flex-shrink: 0;
    cursor: grab;
    color: #9ca3af;
    transition: all 0.2s ease;
    border-radius: 8px;
    margin: -8px 0;
    padding: 8px 4px;
}

.drag-handle:hover {
    color: var(--primary-blue);
    background: rgba(74, 123, 167, 0.1);
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle svg {
    width: 20px;
    height: 20px;
}

/* Sortable states */
.sortable-ghost {
    opacity: 0.4;
    background: #e0f2fe !important;
    border: 2px dashed var(--primary-blue) !important;
}

.sortable-chosen {
    box-shadow: 0 8px 25px rgba(74, 123, 167, 0.3) !important;
    transform: rotate(1deg);
}

.sortable-drag {
    opacity: 1 !important;
    background: white !important;
    box-shadow: 0 12px 30px rgba(74, 123, 167, 0.4) !important;
}

/* Exercises sortable container */
.exercises-sortable {
    min-height: 50px;
}

/* Order notification */
.orden-notificacion {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1001;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.orden-notificacion.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.orden-notificacion.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.orden-notificacion.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

/* Alert error */
.alert-error {
    position: fixed !important;
    top: 80px !important;
    left: 50% !important;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    padding: 14px 24px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 14px;
    z-index: 9998 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    animation: slideDownFade 0.3s ease-out;
    transition: all 0.3s ease;
}

.alert-error svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Responsive adjustments for drag handle */
@media (max-width: 480px) {
    .drag-handle {
        width: 28px;
    }

    .drag-hint {
        font-size: 11px;
        padding: 3px 8px;
    }
}
