/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: #333;
}

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

/* Header */
.header {
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(91, 46, 139, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
}

.header-logo {
    height: 80px;
    width: auto;
    position: absolute;
    left: 20px;
}

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

.header-text h1 {
    color: #5B2E8B;
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.header-text p {
    color: #666;
    font-size: 1.1rem;
    margin: 0;
}

/* School Selector */
.school-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.school-selector label {
    font-weight: 600;
    color: #5B2E8B;
}

.school-selector select {
    padding: 8px 15px;
    border: 2px solid #5B2E8B;
    border-radius: 8px;
    background: white;
    color: #333;
    font-size: 1rem;
    min-width: 200px;
}

.school-selector select:focus {
    outline: none;
    border-color: #7B3F9B;
    box-shadow: 0 0 0 3px rgba(91, 46, 139, 0.1);
}

.add-school-btn {
    background: #5B2E8B;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.add-school-btn:hover {
    background: #4a2570;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(91, 46, 139, 0.3);
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    background: white;
    border-radius: 15px;
    padding: 10px;
    box-shadow: 0 4px 20px rgba(91, 46, 139, 0.1);
}

.tab-button {
    background: transparent;
    border: none;
    padding: 15px 30px;
    margin: 0 5px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: #666;
    transition: all 0.3s ease;
    position: relative;
}

.tab-button:hover {
    background: rgba(91, 46, 139, 0.1);
    color: #5B2E8B;
}

.tab-button.active {
    background: #5B2E8B;
    color: white;
    box-shadow: 0 4px 15px rgba(91, 46, 139, 0.3);
}

/* Main Content */
.main-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(91, 46, 139, 0.1);
    min-height: 500px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #5B2E8B 0%, #7B3F9B 100%);
    color: white;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(91, 46, 139, 0.2);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    opacity: 0.9;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

/* Hover Chart Styles */
.hover-chart-card {
    position: relative;
    cursor: pointer;
}

.chart-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 249, 250, 0.9) 100%);
    border: 1px solid rgba(91, 46, 139, 0.08);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(91, 46, 139, 0.08), 0 8px 16px rgba(0, 0, 0, 0.04);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 15px;
    backdrop-filter: blur(20px);
    min-width: 340px;
}

.hover-chart-card:hover .chart-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

.chart-tooltip canvas {
    display: block;
    border-radius: 8px;
}

.chart-tooltip::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(91, 46, 139, 0.1);
}

/* District Overview Section */
.district-overview-section {
    margin-bottom: 40px;
}

.district-overview-section h2 {
    color: #5B2E8B;
    margin-bottom: 20px;
    font-size: 1.8rem;
    text-align: center;
}

.schools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.school-info-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(91, 46, 139, 0.1);
    border: 2px solid #f0f0f0;
}

.school-info-card h4 {
    color: #5B2E8B;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.school-logo {
    text-align: center;
    margin-bottom: 15px;
}

.school-details h3 {
    color: #5B2E8B;
    margin-bottom: 10px;
    font-size: 1.4rem;
}

.school-details p {
    margin: 5px 0;
    color: #666;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
    padding: 5px 0;
    border-bottom: 1px solid #f0f0f0;
}

.detail-label {
    font-weight: 600;
    color: #5B2E8B;
}

.detail-row span:last-child {
    color: #333;
}

/* Stats Section */
.stats-section {
    margin-top: 30px;
}

.stats-section h2 {
    color: #5B2E8B;
    margin-bottom: 20px;
    font-size: 1.8rem;
    text-align: center;
}

/* District Overall Score */
.district-overall-score {
    background: linear-gradient(135deg, #5B2E8B 0%, #7B3F9F 100%);
    color: white;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(91, 46, 139, 0.3);
}

.district-overall-score h3 {
    margin-bottom: 15px;
    font-size: 1.4rem;
    font-weight: 600;
}

.overall-score-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.overall-score-display .stars {
    display: flex;
    gap: 5px;
}

.overall-score-display .star {
    font-size: 2rem;
    color: #ffd700;
    transition: all 0.2s ease;
}

.overall-score-display .score-text {
    font-size: 1.5rem;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.district-overall-score .score-description {
    font-size: 0.95rem;
    opacity: 0.9;
    font-style: italic;
}

/* Board Goal Score Section */
.board-goal-score {
    background: linear-gradient(135deg, #5B2E8B 0%, #7B3F9B 100%);
    color: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(91, 46, 139, 0.2);
}

.board-goal-score h2 {
    margin-bottom: 20px;
    font-size: 1.8rem;
    text-align: center;
}

.star-rating-display {
    text-align: center;
}

.overall-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.score-label {
    font-size: 1.2rem;
    font-weight: 600;
}

.stars {
    display: flex;
    gap: 5px;
}

.star {
    font-size: 2rem;
    color: #ffd700;
    transition: all 0.3s ease;
}

.star:hover {
    transform: scale(1.2);
    cursor: help;
}

.score-text {
    font-size: 1.4rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 20px;
}

.score-description {
    font-size: 1.1rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* KPI Section */
.kpi-section {
    margin-bottom: 30px;
}

.kpi-section h3 {
    color: #5B2E8B;
    margin-bottom: 20px;
    font-size: 1.5rem;
    text-align: center;
}

.kpi-list {
    display: grid;
    gap: 15px;
}

.kpi-item {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border-left: 4px solid #5B2E8B;
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.kpi-name {
    font-weight: 600;
    color: #5B2E8B;
    font-size: 1.1rem;
}

.kpi-weight {
    background: #5B2E8B;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.9rem;
}

.kpi-score {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.kpi-stars-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.kpi-score-value {
    font-weight: 700;
    background: rgba(91, 46, 139, 0.1);
    color: #5B2E8B;
    padding: 6px 10px;
    border-radius: 999px;
}

.kpi-performance-metric {
    font-weight: 600;
    color: #374151;
    max-width: 420px;
}

.kpi-hover-hint {
    color: #6B7280;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: help;
    text-decoration: underline dotted rgba(107, 114, 128, 0.8);
    margin-top: -2px; /* visually tighten below the star row */
}

.kpi-star-meaning-inline {
    display: none;
    font-weight: 600;
    color: #111827;
    max-width: 520px;
    line-height: 1.2;
    background: rgba(91, 46, 139, 0.06);
    border: 1px solid rgba(91, 46, 139, 0.14);
    padding: 10px 12px;
    border-radius: 12px;
    white-space: pre-line;
}

.kpi-star-meaning-inline.show {
    display: block;
}

.kpi-stars {
    display: flex;
    gap: 2px;
}

.kpi-star {
    font-size: 1.2rem;
    color: #ddd;
    transition: all 0.2s ease;
    cursor: help;
}

.kpi-star.filled {
    color: #ffd700;
}

.kpi-star:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.kpi-description {
    color: #666;
    margin-bottom: 8px;
}

.kpi-why {
    font-size: 0.9rem;
    color: #888;
    font-style: italic;
}

.kpi-celebrations {
    background: #d4edda;
    color: #155724;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 12px 0;
    font-size: 0.9rem;
    border-left: 4px solid #28a745;
}

.kpi-celebrations strong {
    color: #0d4a1a;
    font-weight: 600;
}

.kpi-ofis {
    background: #fff3cd;
    color: #856404;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 12px 0;
    font-size: 0.9rem;
    border-left: 4px solid #ffc107;
}

.kpi-ofis strong {
    color: #6c4a00;
    font-weight: 600;
}

/* KPI Star Meaning Key (4th KPI only) */
.kpi-star-key {
    margin: 10px 0 12px 0;
    padding: 12px 16px;
    border-radius: 10px;
    background: rgba(91, 46, 139, 0.06);
    border-left: 4px solid #5B2E8B;
}

.kpi-star-key-title {
    font-weight: 600;
    color: #5B2E8B;
    margin-bottom: 6px;
    font-size: 1.0rem;
}

.kpi-star-key-row {
    display: flex;
    gap: 8px;
    margin: 6px 0;
}

.kpi-star-key-label {
    font-weight: 600;
    color: #374151;
    min-width: 80px;
    flex-shrink: 0;
    font-size: 0.95rem;
}

.kpi-star-key-text {
    color: #111827;
    white-space: pre-line;
    line-height: 1.2;
    font-size: 0.95rem;
}

/* Charts Section */
.charts-section {
    margin-top: 30px;
}

.chart-container {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.chart-container h2 {
    color: #5B2E8B;
    margin-bottom: 20px;
    font-size: 1.5rem;
    text-align: center;
}

.chart-container canvas {
    max-height: 400px;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(91, 46, 139, 0.1);
}

.refresh-button {
    background: #5B2E8B;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.refresh-button:hover {
    background: #4a2570;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(91, 46, 139, 0.3);
}

/* Loading states */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: #5B2E8B;
    font-size: 1.2rem;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #5B2E8B;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 15px;
    right: 20px;
}

.close:hover {
    color: #5B2E8B;
}

.modal h2 {
    color: #5B2E8B;
    margin-bottom: 20px;
    text-align: center;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #5B2E8B;
    box-shadow: 0 0 0 3px rgba(91, 46, 139, 0.1);
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
}

.submit-btn {
    background: #5B2E8B;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.submit-btn:hover {
    background: #4a2570;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(91, 46, 139, 0.3);
}

.cancel-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.cancel-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .school-selector {
        flex-direction: column;
        align-items: stretch;
    }
    
    .school-selector select {
        min-width: auto;
    }
    
    .tab-navigation {
        flex-wrap: wrap;
    }
    
    .tab-button {
        padding: 12px 20px;
        margin: 5px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .modal-content {
        margin: 10% auto;
        width: 95%;
        padding: 20px;
    }
}

/* Star tooltip styles */
.star-tooltip {
    position: absolute;
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1000;
    max-width: 300px;
    white-space: pre-line;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.star-tooltip.show {
    opacity: 1;
}

/* Star hover effects */
.star {
    transition: all 0.2s ease-in-out;
}

.star:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}
