/* ============================================
   HYPERFORZA RUTINA VIEWER – STYLES
   ============================================ */

:root {
    --red: #fe0000;
    --red-dark: #cc0000;
    --red-glow: rgba(254, 0, 0, 0.25);
    --red-subtle: rgba(254, 0, 0, 0.08);
    --bg: #0a0a0a;
    --bg-card: #111111;
    --bg-card-hover: #1a1a1a;
    --bg-option: #151515;
    --border: #222222;
    --border-hover: #333333;
    --text: #ffffff;
    --text-secondary: #999999;
    --text-muted: #666666;
    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.5);
    --green: #4ade80;
    --yellow: #facc15;
}

/* ---- RESET ---- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.text-red {
    color: var(--red);
}

/* ---- BACKGROUND ---- */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(254, 0, 0, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(254, 0, 0, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

/* ---- TOP BAR ---- */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.back-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color var(--transition);
}

.back-link svg {
    width: 18px;
    height: 18px;
}

.back-link:hover {
    color: var(--red);
}

.nav-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

/* ---- UPLOAD SECTION ---- */
.upload-section {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: 40px 24px;
}

.upload-container {
    text-align: center;
    max-width: 480px;
    width: 100%;
}

.upload-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--red-subtle);
    border-radius: 50%;
}

.upload-icon svg {
    width: 40px;
    height: 40px;
    stroke: var(--red);
}

.upload-title {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 800;
    margin-bottom: 8px;
}

.upload-desc {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

/* Drop Zone */
.drop-zone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-card);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--red);
    background: rgba(254, 0, 0, 0.05);
}

.drop-zone.drag-over {
    transform: scale(1.02);
}

.drop-icon {
    width: 48px;
    height: 48px;
    stroke: var(--text-muted);
    margin: 0 auto 16px;
    display: block;
    transition: stroke var(--transition);
}

.drop-zone:hover .drop-icon {
    stroke: var(--red);
}

.drop-text {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.drop-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 16px;
}

/* ---- Text Import Zone ---- */

.import-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.import-divider::before,
.import-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.text-import-zone {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.json-textarea {
    width: 100%;
    min-height: 120px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.json-textarea::placeholder {
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-style: italic;
}

.json-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(254, 0, 0, 0.1);
}

.btn-accent {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: rgba(254, 0, 0, 0.08);
    border: 1px solid rgba(254, 0, 0, 0.2);
    color: var(--accent);
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-accent svg {
    width: 18px;
    height: 18px;
}

.btn-accent:hover {
    background: rgba(254, 0, 0, 0.15);
    border-color: var(--accent);
    transform: translateY(-1px);
}

/* ---- ACTION BAR ---- */
.action-bar {
    position: sticky;
    top: 60px;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 24px;
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.bottom-bar {
    position: static;
    border-bottom: none;
    border-top: 1px solid var(--border);
    padding: 24px;
    margin-top: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-xs);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--red);
    color: white;
}

.btn-primary:hover {
    background: var(--red-dark);
    box-shadow: 0 4px 20px rgba(254, 0, 0, 0.3);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1rem;
}

/* ---- ROUTINE CONTENT ---- */
.routine-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 24px;
    position: relative;
    z-index: 1;
}

/* Header */
.routine-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
}

.routine-header .logo-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 20px rgba(254, 0, 0, 0.3));
}

.routine-header h1 {
    font-size: clamp(1.5rem, 3.5vw, 2.2rem);
    font-weight: 800;
    margin-bottom: 8px;
}

.routine-header .client-name {
    font-size: 1.1rem;
    color: var(--red);
    font-weight: 600;
}

/* Section Card */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
}

.section-title {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title .icon {
    font-size: 1.4rem;
}

.section-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.6;
}

/* Info Table */
.info-table {
    width: 100%;
    border-collapse: collapse;
}

.info-table tr {
    border-bottom: 1px solid var(--border);
}

.info-table tr:last-child {
    border-bottom: none;
}

.info-table td {
    padding: 12px 16px;
    font-size: 0.95rem;
}

.info-table td:first-child {
    font-weight: 600;
    color: var(--text-secondary);
    width: 45%;
}

.info-table td:last-child {
    color: var(--text);
    font-weight: 500;
}

/* Day Card */
.day-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}

.day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(254, 0, 0, 0.08), transparent);
    border-bottom: 1px solid var(--border);
}

.day-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.day-number {
    width: 44px;
    height: 44px;
    background: var(--red);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.day-info h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.day-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.day-meta {
    display: flex;
    gap: 16px;
}

.day-meta-item {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.day-meta-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

/* Exercise Table */
.exercise-table {
    width: 100%;
    border-collapse: collapse;
}

.exercise-table thead {
    background: rgba(254, 0, 0, 0.05);
}

.exercise-table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.exercise-table td {
    padding: 14px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(34, 34, 34, 0.5);
    vertical-align: top;
}

.exercise-table tr:last-child td {
    border-bottom: none;
}

.exercise-name {
    font-weight: 600;
    color: var(--text);
}

.exercise-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--red-subtle);
    color: var(--red);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 8px;
}

.exercise-tips {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 4px;
}

.rpe-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 10px;
    background: var(--red-subtle);
    color: var(--red);
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
}

/* Rest Day */
.rest-day {
    padding: 32px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 1rem;
}

.rest-day .rest-emoji {
    font-size: 2rem;
    margin-bottom: 12px;
    display: block;
}

/* Notes List */
.notes-list {
    list-style: none;
    padding: 0;
}

.notes-list li {
    padding: 12px 0;
    padding-left: 24px;
    position: relative;
    font-size: 0.95rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(34, 34, 34, 0.5);
}

.notes-list li:last-child {
    border-bottom: none;
}

.notes-list li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--red);
    font-weight: bold;
}

/* Progression Methods */
.method-card {
    background: var(--bg-option);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 12px;
}

.method-card:last-child {
    margin-bottom: 0;
}

.method-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--red);
    margin-bottom: 4px;
}

.method-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Deload Instructions */
.deload-list {
    list-style: none;
    padding: 0;
}

.deload-list li {
    padding: 10px 0 10px 28px;
    position: relative;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.deload-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--green);
    font-weight: bold;
}

/* RPE Levels */
.rpe-level {
    background: var(--bg-option);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 12px;
}

.rpe-level:last-child {
    margin-bottom: 0;
}

.rpe-level-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
}

.rpe-level-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.rpe-shortcut {
    margin-top: 16px;
    padding: 16px 20px;
    background: rgba(254, 0, 0, 0.05);
    border-left: 3px solid var(--red);
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Semaforo */
.semaforo-state {
    background: var(--bg-option);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 12px;
}

.semaforo-state:last-child {
    margin-bottom: 0;
}

.semaforo-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 8px;
}

.semaforo-criteria {
    list-style: none;
    padding: 0;
}

.semaforo-criteria li {
    padding: 4px 0 4px 20px;
    position: relative;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.semaforo-criteria li::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: var(--text-muted);
}

/* ---- LOADING OVERLAY ---- */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.loading-text {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* ---- ERROR MESSAGE ---- */
.error-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a0000;
    border: 1px solid var(--red);
    color: var(--red);
    padding: 14px 24px;
    border-radius: var(--radius-xs);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 9999;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .day-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .day-meta {
        width: 100%;
        justify-content: space-around;
        padding-top: 8px;
        border-top: 1px solid var(--border);
    }

    .exercise-table th:nth-child(4),
    .exercise-table td:nth-child(4),
    .exercise-table th:nth-child(5),
    .exercise-table td:nth-child(5) {
        display: none;
    }

    .action-bar {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .section-card {
        padding: 20px 16px;
    }

    .day-header {
        padding: 16px;
    }

    .exercise-table th,
    .exercise-table td {
        padding: 10px 8px;
        font-size: 0.8rem;
    }

    .routine-content {
        padding: 20px 12px;
    }
}

/* ---- PDF print override ---- */
@media print {
    body {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        background: #0a0a0a !important;
        color: #ffffff !important;
    }

    .routine-section {
        display: block !important;
    }

    .top-bar,
    .action-bar,
    .bottom-bar,
    .bg-grid {
        display: none !important;
    }

    .routine-header {
        page-break-after: always;
    }

    .section-card {
        break-inside: avoid;
        page-break-inside: avoid;
        background-color: #111111 !important;
        color: #ffffff !important;
        border: 1px solid #222222 !important;
    }

    .day-card {
        page-break-before: always;
        break-inside: avoid;
        page-break-inside: avoid;
        background-color: #111111 !important;
        color: #ffffff !important;
        border: 1px solid #222222 !important;
    }
}