/* CSS Variables & Theme Setup */
:root {
    --primary-color: #1e3a8a; /* Deep Navy Blue */
    --primary-light: #3b82f6; /* Soft Blue */
    --accent-color: #f97316; /* Warm Orange (Question border) */
    --accent-red: #dc2626; /* Crimson Red for Component/Competencia */
    --success-color: #10b981; /* Emerald Green */
    --bg-color: #f8fafc; /* Slate Off-White */
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
}

/* Base Layout Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header & Navbar */
header.app-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
}

.brand {
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand span {
    color: var(--accent-color);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-links a:hover {
    color: var(--primary-light);
}

.user-badge {
    background: #eff6ff;
    color: var(--primary-color);
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
}

/* Glassmorphic Auth Cards */
.auth-wrapper {
    min-height: 90vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, #eff6ff 0%, #faf5ff 100%);
}

.auth-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    padding: 2.5rem;
    transition: transform 0.3s ease;
}

.auth-card h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    font-weight: 800;
    color: var(--primary-color);
    text-align: center;
}

.auth-card p.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    background-color: #ffffff;
    color: var(--text-main);
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Custom Select Dropdowns */
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #172554;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

.btn-accent {
    background-color: var(--accent-color);
    color: #ffffff;
}

.btn-accent:hover {
    background-color: #ea580c;
    transform: translateY(-1px);
}

.btn-danger {
    background-color: #ef4444;
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

.btn-full {
    width: 100%;
}

/* Dashboard Elements */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.card h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Evaluation Table / List styling */
.eval-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.eval-table th, .eval-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.eval-table th {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.eval-table tr:hover {
    background-color: #f8fafc;
}

/* Question Creator layout */
.creator-wrapper {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .creator-wrapper {
        grid-template-columns: 1fr;
    }
}

.creator-sidebar {
    position: sticky;
    top: 90px;
    height: calc(100vh - 120px);
    overflow-y: auto;
}

@media (max-width: 1024px) {
    .creator-sidebar {
        position: relative;
        top: 0;
        height: auto;
    }
}

/* Collapsible / Question Accordion */
.q-card-list {
    margin-top: 1rem;
}

.q-box {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1.5rem;
    background: #ffffff;
    overflow: hidden;
}

.q-box-header {
    background-color: #f8fafc;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}

.q-box-body {
    padding: 1.25rem;
}

.q-box-meta {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-color);
    color: var(--accent-red);
    font-weight: bold;
    font-size: 0.9rem;
}

/* Question Group Card inside Creator */
.group-card {
    border-left: 5px solid var(--primary-light);
    background-color: #f0fdf4;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0 8px 8px 0;
}

.group-title {
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* Dynamic Table input styles */
.table-builder {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #f8fafc;
}

.table-builder-grid {
    width: 100%;
    margin-bottom: 0.75rem;
    border-collapse: collapse;
}

.table-builder-grid input {
    width: 100%;
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
}

/* ==========================================================================
   HIGH FIDELITY PRINT STYLES - Recreating the image structure
   ========================================================================== */
.print-container {
    background-color: #ffffff;
    max-width: 850px;
    margin: 1rem auto;
    padding: 1.5in 0.8in 1.5in 0.5in; /* custom margins to fit content nicely */
    border: 1px solid #ccc;
    box-shadow: var(--shadow-lg);
    position: relative;
    font-size: 13px;
    line-height: 1.45;
}

/* Printable layout decorative red side lines */
.print-container::after {
    content: "";
    position: absolute;
    top: 1.5in;
    right: 0.45in;
    bottom: 1.5in;
    width: 2px;
    background-color: #dc2626; /* Red side line */
    z-index: 10;
}

/* Vertical Text label along the right margin */
.print-vertical-label {
    position: absolute;
    right: 0.18in;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
    transform-origin: center right;
    font-family: Impact, sans-serif;
    color: #64748b;
    font-size: 14px;
    letter-spacing: 5px;
    text-transform: uppercase;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
}

/* Print Header Area */
.print-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 4px solid var(--primary-color);
    padding-bottom: 0.75rem;
}

.print-header-logo {
    width: 65px;
    height: 45px;
    object-fit: contain;
}

.print-header-title {
    font-family: 'Montserrat', 'Impact', sans-serif;
    font-size: 26px;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--primary-color);
    letter-spacing: 1.5px;
    text-align: center;
}

.print-subtitle {
    font-weight: 800;
    font-size: 12px;
    color: var(--primary-light);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1.5rem;
}

/* Question Group Context Block on print */
.print-group-context {
    margin: 1.5rem 0;
    padding-right: 0.5in; /* Leave room for side label */
}

.print-group-title {
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    color: var(--text-main);
    text-align: center;
}

.print-group-text {
    font-style: italic;
    margin-bottom: 1rem;
}

/* Context Table styled exactly as image */
.print-context-table {
    width: 70%;
    margin: 0.75rem auto;
    border-collapse: collapse;
    font-size: 12px;
}

.print-context-table th, .print-context-table td {
    border: 1px solid #000000;
    padding: 0.35rem 0.75rem;
    text-align: left;
}

.print-context-table th {
    background-color: #f1f5f9;
    font-weight: bold;
}

/* Standalone & Grouped Question Box */
.print-question-box {
    border: 2px solid var(--accent-color); /* Orange border as image */
    border-radius: 0px; /* Sharp corners like in the reference image */
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    position: relative;
    background: #ffffff;
    page-break-inside: avoid; /* Prevent split questions across print pages */
    margin-right: 0.5in; /* Room for the vertical label */
}

.print-question-text {
    font-weight: 500;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
}

.print-question-number {
    font-weight: bold;
    color: var(--text-main);
}

.print-options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.4rem;
    padding-left: 2rem;
    margin-bottom: 1rem;
}

.print-option {
    display: flex;
    gap: 0.5rem;
}

.print-option-letter {
    font-weight: bold;
}

/* Print Metadata bottom footer inside orange box */
.print-question-footer {
    border-top: 1px solid var(--accent-color);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
    font-size: 11px;
    color: var(--text-main);
}

.print-meta-label {
    color: var(--accent-red);
    font-weight: bold;
}

/* Print Control Float Bar */
.print-controls {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem 2rem;
    border-radius: 9999px;
    box-shadow: var(--shadow-lg);
    display: flex;
    gap: 1rem;
    z-index: 1000;
    border: 1px solid var(--border-color);
}

/* Page Break Helper */
.page-break {
    page-break-before: always;
}

/* ==========================================================================
   LICENSE WARNING & WATERMARK STYLES
   ========================================================================== */
.license-alert-banner {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    padding: 0.6rem 1.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.license-alert-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.license-alert-link {
    color: #ffffff;
    text-decoration: underline;
    font-weight: 700;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.license-alert-link:hover {
    opacity: 0.85;
}

.print-watermark {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.print-watermark::before {
    content: "VERSIÓN DE PRUEBA";
    font-size: 5.5rem;
    font-weight: 900;
    color: rgba(220, 38, 38, 0.05); /* Very subtle red */
    font-family: 'Montserrat', sans-serif;
    transform: rotate(-30deg);
    white-space: nowrap;
    letter-spacing: 5px;
}

/* ==========================================================================
   EVALUATION COVER PAGE STYLES
   ========================================================================== */
.print-cover-container {
    background-color: #ffffff;
    max-width: 850px;
    margin: 1rem auto;
    padding: 1.5in 0.8in 1.5in 0.8in;
    border: 1px solid #ccc;
    box-shadow: var(--shadow-lg);
    position: relative;
    box-sizing: border-box;
}

.print-cover-page {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 7.5in;
    box-sizing: border-box;
}

.print-cover-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 1.25rem;
    margin-bottom: 1.5rem;
}

.print-cover-logo {
    max-height: 80px;
    width: auto;
    object-fit: contain;
}

.print-cover-inst-name {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-align: center;
}

.print-cover-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.print-cover-title {
    font-family: 'Montserrat', 'Impact', sans-serif;
    font-size: 32px;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--primary-color);
    letter-spacing: 1.5px;
    text-align: center;
}

.print-cover-subtitle {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    max-width: 90%;
    margin-bottom: 1rem;
}

.print-cover-image-container {
    width: 100%;
    max-height: 280px;
    display: flex;
    justify-content: center;
}

.print-cover-image {
    max-height: 280px;
    max-width: 80%;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.print-cover-footer {
    margin-top: auto;
}

.print-cover-student-form {
    border: 1px solid #000000;
    padding: 1.25rem;
    background: #fafafa;
}

.form-row-print {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
}

.form-field-print {
    font-size: 12px;
    flex-grow: 1;
}

/* ==========================================================================
   NATIVE BROWSER PRINT CONFIGURATION
   ========================================================================== */
@media print {
    /* Hide layout items that shouldn't print */
    header.app-header,
    .print-controls,
    .btn,
    .license-alert-banner,
    nav {
        display: none !important;
    }

    body {
        background-color: #ffffff !important;
        color: #000000 !important;
    }

    .print-container {
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Red side line position absolute layout correction */
    .print-container::after {
        top: 0 !important;
        right: 0.3in !important;
        bottom: 0 !important;
        height: 100% !important;
    }

    .print-vertical-label {
        right: 0in !important;
    }

    /* Replicate watermark on every page when printed */
    .print-watermark {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        z-index: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .print-watermark::before {
        font-size: 6.5rem !important;
        color: rgba(220, 38, 38, 0.05) !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Cover print overrides */
    .print-cover-container {
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .print-cover-page {
        min-height: 100% !important;
        page-break-inside: avoid;
        page-break-after: always;
        break-after: page;
        padding-right: 0.3in !important;
    }

    .print-cover-student-form {
        background: transparent !important;
    }

    /* Page Setup */
    @page {
        size: letter portrait;
        margin: 0.5in 0.3in 0.5in 0.5in;
    }
}
