/**
 * GABS Report Tool - Main Stylesheet
 * 
 * This CSS file provides comprehensive styling for the GABS Assessment Report Generator,
 * including responsive design, modern UI components, and enhanced print optimization
 * for single-page landscape PDF exports.
 * 
 * Key Features:
 * - Modern gradient design with professional styling
 * - Responsive layout that works on all devices
 * - Enhanced print styles for landscape A4 PDF export
 * - Color-coded score indicators (red/yellow/green)
 * - Optimized table layouts for complex data display
 * - Accessibility considerations with proper contrast
 * 
 * @author GABS Report Tool Team
 * @version 2.0.0
 * @since 2024
 */

/**
 * RESET AND BASE STYLES
 * Normalize browser defaults and establish base typography
 */

/* Universal box-sizing reset for consistent layout behavior */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box; /* Includes padding and border in element's total width/height */
}

/* Base body styles with modern font stack and gradient background */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #333;
    line-height: 1.6; /* Improves readability */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 40px;
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.header-logo {
    height: 60px;
}

.header-text {
    text-align: left;
}

.header h1 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 2.5em;
    font-weight: 600;
}

.subtitle {
    color: #7f8c8d;
    font-size: 1.1em;
}

/* Upload Section */
.upload-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.upload-step {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.upload-step h2 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.5em;
    font-weight: 500;
}

.upload-step p {
    color: #7f8c8d;
    margin-bottom: 20px;
}

.file-upload {
    position: relative;
}

.file-upload input[type="file"] {
    display: none;
}

.upload-btn {
    display: inline-block;
    padding: 12px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: 500;
    text-decoration: none;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.file-status {
    display: block;
    margin-top: 10px;
    color: #7f8c8d;
    font-size: 0.9em;
}

.file-status.success {
    color: #27ae60;
    font-weight: 500;
}

.file-status.error {
    color: #e74c3c;
    font-weight: 500;
}

/* Controls Section */
.controls-section {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.report-controls h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.4em;
}

.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    color: #2c3e50;
    font-weight: 500;
    margin-bottom: 8px;
}

.control-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    font-size: 1em;
    background: white;
    transition: border-color 0.3s;
}

.control-group select:focus {
    outline: none;
    border-color: #667eea;
}

.generate-btn, .export-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-right: 15px;
}

.generate-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.export-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.generate-btn:hover, .export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* Report Section */
.report-section {
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    overflow: hidden;
}

.report-table-container {
    overflow-x: auto;
    display: block;
    width: 100%;
    padding: 1px; /* Fix for box-shadow clipping */
}

/* Report Output Styles */
.report-container {
    padding: 30px;
}

/* Report Header with Logo Layout */
.report-header {
    margin-bottom: 30px;
    border-bottom: 3px solid #2c3e50;
    padding-bottom: 20px;
}

.report-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.report-title-section {
    flex: 1;
    text-align: left;
}

.report-logo-section {
    flex-shrink: 0;
    text-align: right;
}

.report-title {
    font-size: 2em;
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.report-filename-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: #ecf0f1;
    border-radius: 6px;
    font-size: 0.5em;
    font-weight: 500;
    color: #2c3e50;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.report-filename-container:hover {
    background: #d5dbdb;
    border-color: #667eea;
}

.report-filename {
    outline: none;
    background: transparent;
    border: none;
    min-width: 100px;
    max-width: 400px;
}

.report-filename:focus {
    background: white;
    padding: 2px 6px;
    border-radius: 3px;
}

.edit-icon {
    color: #667eea;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.edit-icon:hover {
    transform: scale(1.2);
    color: #764ba2;
}

.report-date {
    color: #7f8c8d;
    font-size: 1.1em;
}

.report-gabs-logo {
    height: 80px;
    max-width: 200px;
    object-fit: contain;
}

/* Report Footer */
.report-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #bdc3c7;
    text-align: center;
}

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.footer-text {
    color: #7f8c8d;
    font-size: 0.9em;
    font-weight: 500;
}

.report-alpha-logo {
    height: 40px;
    max-width: 150px;
    object-fit: contain;
}

/* Report Tables */
.report-table {
    width: 100%;
    min-width: 1600px; /* Increase min-width to ensure scroll always appears */
    border-collapse: collapse;
    margin-bottom: 30px;
    font-size: 0.9em;
}

.report-table th,
.report-table td {
    padding: 12px 8px;
    text-align: center;
    border: 1px solid #bdc3c7;
    vertical-align: middle;
}

.report-table th {
    background: #2c3e50;
    color: white;
    font-weight: 500;
    font-size: 0.85em;
}

.report-table tbody tr:nth-child(even) {
    background: #ecf0f1;
}

.report-table tbody tr:hover {
    background: #d5dbdb;
}

/* Category headers */
.category-header {
    background: #34495e !important;
    color: white !important;
    font-weight: 600;
    font-size: 0.8em;
}

.sub-category-header {
    background: #5d6d7e !important;
    color: white !important;
    font-size: 0.75em;
}

/* Score styling - RED < 50%, YELLOW 50-99%, GREEN 100% */
.score-excellent {
    background-color: #27ae60; /* Green for 100% */
    color: white;
    font-weight: bold;
}

.score-good {
    background-color: #f39c12; /* Yellow/Orange for 50-99% */
    color: white;
    font-weight: bold;
}

.score-needs-improvement {
    background-color: #e74c3c; /* Red for < 50% */
    color: white;
    font-weight: bold;
}

/* RECO column styling - Four-tier system */
.reco-highly-recommended {
    background-color: #0e6f2f !important; /* Dark green for R+ (Highly Recommended) */
    color: white !important;
    font-weight: bold !important;
    font-size: 1.1em !important;
}

.reco-recommended {
    background-color: #27ae60 !important; /* Green for R (Recommended) */
    color: white !important;
    font-weight: bold !important;
    font-size: 1.1em !important;
}

.reco-partially-recommended {
    background-color: #f1c40f !important; /* Bright yellow for P/R (Partially Recommended) */
    color: #333 !important; /* Dark text for contrast on yellow */
    font-weight: bold !important;
    font-size: 1.1em !important;
}

.reco-not-recommended {
    background-color: #e74c3c !important; /* Red for N/R (Not Recommended) */
    color: white !important;
    font-weight: bold !important;
    font-size: 1.1em !important;
}

/* RECO Legend Styles */
.reco-legend {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 20px;
}

.legend-title {
    color: #2c3e50;
    font-size: 1em;
    margin-bottom: 10px;
    text-align: center;
    font-weight: 600;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.legend-badge {
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9em;
    min-width: 42px;
    text-align: center;
    flex-shrink: 0;
}

.legend-content {
    flex: 1;
}

.legend-content strong {
    display: block;
    color: #2c3e50;
    margin-bottom: 2px;
    font-size: 0.85em;
}

.legend-content p {
    margin: 0;
    color: #6c757d;
    font-size: 0.75em;
    line-height: 1.3;
}

.legend-note {
    text-align: center;
    color: #6c757d;
    font-size: 0.75em;
    margin: 0;
    padding-top: 8px;
    border-top: 1px solid #dee2e6;
}

/* Individual candidate info */
.candidate-info {
    background: #ecf0f1;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.candidate-info h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.info-item {
    display: flex;
    align-items: center;
}

.info-label {
    font-weight: 600;
    color: #34495e;
    min-width: 100px;
}

.info-value {
    color: #2c3e50;
}

/* Status Messages */
.status-section {
    margin-top: 20px;
}

.status-message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.status-success {
    background: #d5edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.status-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    border-top-color: #667eea;
    animation: spin 1s ease-in-out infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .upload-section {
        grid-template-columns: 1fr;
    }
    
    .container {
        padding: 10px;
    }
    
    .header {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .report-table {
        font-size: 0.8em;
    }
    
    .report-table th,
    .report-table td {
        padding: 8px 4px;
    }
}

/* Footer Styles */
.footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.footer-logo {
    height: 40px;
}

/* Enhanced Print Styles for Single-Page Landscape */
@media print {
    @page {
        size: A4 landscape;
        margin: 0.5in;
    }
    
    * {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    body {
        background: white !important;
        color: black !important;
        font-size: 8pt !important;
        line-height: 1.2 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .header,
    .upload-section,
    .controls-section,
    .status-section,
    .footer {
        display: none !important;
    }
    
    .container {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .report-section {
        box-shadow: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
    }
    
    .report-container {
        padding: 10px !important;
        margin: 0 !important;
    }
    
    /* Print styles for report header with logos */
    .report-header {
        margin-bottom: 5px !important;
        padding-bottom: 5px !important;
        border-bottom: 1px solid #333 !important;
    }
    
    .report-header-content {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 20px !important;
    }
    
    .report-title-section {
        flex: 1 !important;
        text-align: left !important;
    }
    
    .report-logo-section {
        flex-shrink: 0 !important;
        text-align: right !important;
    }
    
    .report-title {
        font-size: 11pt !important;
        color: #333 !important;
        font-weight: bold !important;
        margin-bottom: 0px !important;
        display: block !important;
        line-height: 1.2 !important;
    }
    
    .report-filename-container {
        display: inline-block !important;
        padding: 2px 8px !important;
        background: #ecf0f1 !important;
        border-radius: 4px !important;
        font-size: 0.6em !important;
        font-weight: normal !important;
        margin-left: 8px !important;
        border: 1px solid #bdc3c7 !important;
    }
    
    .report-filename {
        background: transparent !important;
        border: none !important;
    }
    
    .report-date {
        font-size: 8pt !important;
        color: #666 !important;
        margin-top: 2px !important;
    }
    
    .report-gabs-logo {
        height: 30px !important;
        max-width: 80px !important;
        object-fit: contain !important;
    }
    
    /* Print styles for report footer */
    .report-footer {
        margin-top: 20px !important;
        padding-top: 10px !important;
        border-top: 1px solid #666 !important;
        text-align: center !important;
        page-break-inside: avoid !important;
    }
    
    .footer-content {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 10px !important;
        flex-wrap: nowrap !important;
    }
    
    .footer-text {
        color: #666 !important;
        font-size: 8pt !important;
        font-weight: 500 !important;
    }
    
    .report-alpha-logo {
        height: 25px !important;
        max-width: 100px !important;
        object-fit: contain !important;
    }
    
    /* RECO Legend print styles */
    .reco-legend {
        background: #f8f9fa !important;
        border: 1px solid #333 !important;
        border-radius: 5px !important;
        padding: 8px !important;
        margin-bottom: 10px !important;
        page-break-inside: avoid !important;
    }
    
    .legend-title {
        font-size: 10pt !important;
        margin-bottom: 8px !important;
        color: #333 !important;
    }
    
    .legend-items {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
        margin-bottom: 6px !important;
    }
    
    .legend-item {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        background: white !important;
        padding: 5px !important;
        border-radius: 3px !important;
        border: 1px solid #dee2e6 !important;
    }
    
    .legend-badge {
        padding: 3px 6px !important;
        border-radius: 3px !important;
        font-weight: bold !important;
        font-size: 8pt !important;
        min-width: 35px !important;
    }
    
    .legend-content {
        flex: 1 !important;
    }
    
    .legend-content strong {
        font-size: 7pt !important;
        color: #333 !important;
        margin-bottom: 2px !important;
    }
    
    .legend-content p {
        font-size: 6pt !important;
        color: #666 !important;
        line-height: 1.2 !important;
    }
    
    .legend-note {
        font-size: 7pt !important;
        color: #666 !important;
        padding-top: 5px !important;
        border-top: 1px solid #dee2e6 !important;
    }
    
    .candidate-info {
        background: #f5f5f5 !important;
        padding: 10px !important;
        border-radius: 4px !important;
        margin-bottom: 15px !important;
        page-break-inside: avoid !important;
    }
    
    .candidate-info h3 {
        font-size: 12pt !important;
        color: #333 !important;
        margin-bottom: 8px !important;
    }
    
    .info-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
    }
    
    .info-item {
        display: flex !important;
        font-size: 9pt !important;
    }
    
    .info-label {
        font-weight: bold !important;
        color: #333 !important;
        min-width: 60px !important;
    }
    
    .info-value {
        color: #666 !important;
    }
    
    .report-table-container {
        overflow: visible !important;
        width: 100% !important;
        padding: 0 !important;
    }
    
    .report-table {
        width: 100% !important;
        min-width: auto !important;
        border-collapse: collapse !important;
        margin: 0 !important;
        font-size: 7pt !important;
        table-layout: fixed !important;
    }
    
    .report-table th,
    .report-table td {
        border: 1px solid #333 !important;
        padding: 2px 1px !important;
        text-align: center !important;
        vertical-align: middle !important;
        word-wrap: break-word !important;
        overflow: hidden !important;
    }
    
    .report-table thead {
        display: table-header-group !important;
    }
    
    .report-table tbody tr {
        page-break-inside: avoid !important;
    }
    
    .report-table th {
        background: #333 !important;
        color: white !important;
        font-weight: bold !important;
        font-size: 6pt !important;
    }
    
    .report-table tbody tr:nth-child(even) {
        background: #f8f8f8 !important;
    }
    
    .report-table tbody tr:hover {
        background: inherit !important;
    }
    
    /* Score colors for print - RED < 50%, YELLOW 50-99%, GREEN 100% */
    .score-excellent {
        background-color: #27ae60 !important; /* Green for 100% */
        color: white !important;
        font-weight: bold !important;
    }
    
    .score-good {
        background-color: #f39c12 !important; /* Yellow/Orange for 50-99% */
        color: white !important;
        font-weight: bold !important;
    }
    
    .score-needs-improvement {
        background-color: #e74c3c !important; /* Red for < 50% */
        color: white !important;
        font-weight: bold !important;
    }
    
    /* RECO column colors for print - Four-tier system */
    .reco-highly-recommended {
        background-color: #0e6f2f !important; /* Dark green for R+ (Highly Recommended) */
        color: white !important;
        font-weight: bold !important;
        font-size: 8pt !important;
    }
    
    .reco-recommended {
        background-color: #27ae60 !important; /* Green for R (Recommended) */
        color: white !important;
        font-weight: bold !important;
        font-size: 8pt !important;
    }
    
    .reco-partially-recommended {
        background-color: #f1c40f !important; /* Bright yellow for P/R (Partially Recommended) */
        color: #333 !important; /* Dark text for contrast on yellow */
        font-weight: bold !important;
        font-size: 8pt !important;
    }
    
    .reco-not-recommended {
        background-color: #e74c3c !important; /* Red for N/R (Not Recommended) */
        color: white !important;
        font-weight: bold !important;
        font-size: 8pt !important;
    }
    
    /* Adjust column widths for better fit - Now with No. column */
    .report-table th:first-child,
    .report-table td:first-child {
        width: 3% !important;
        min-width: 30px !important;
        max-width: 40px !important;
        font-size: 8pt !important;
    }
    
    .report-table th:nth-child(2),
    .report-table td:nth-child(2) {
        width: 15% !important;
        min-width: 100px !important;
        font-size: 9pt !important;
        font-weight: 600 !important;
    }
    
    .report-table th:nth-child(3),
    .report-table td:nth-child(3) {
        width: 10% !important;
        min-width: 70px !important;
        font-size: 8pt !important;
    }
    
    /* Remaining columns share the space equally */
    .report-table th:not(:first-child):not(:nth-child(2)):not(:nth-child(3)),
    .report-table td:not(:first-child):not(:nth-child(2)):not(:nth-child(3)) {
        width: auto !important;
        min-width: 20px !important;
    }
}

/* Additional print utilities */
.print-only {
    display: none;
}

@media print {
    .print-only {
        display: block !important;
    }
    
    .no-print {
        display: none !important;
    }
}
