:root {
    --primary: #7B1113;
    --primary-light: #9B1D20;
    --primary-dark: #500709;
    --accent: #D4AF37;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-color: #f8fafc;
    --text-main: #1e293b;
    --glass: rgba(255, 255, 255, 0.94);
    --shadow: 0 12px 36px 0 rgba(123, 17, 19, 0.14);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow-x: hidden;
}

.glass {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow);
}

.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: none;
    z-index: 1;
    overflow-y: auto;
}

.screen.active {
    display: flex;
    z-index: 1000;
}

/* Login Screen - Cinematic White & Maroon */
#loginScreen {
    background: radial-gradient(circle at 15% 15%, #FFFFFF 0%, #F1F5F9 55%, #E2E8F0 100%);
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

#loginScreen::before {
    content: '';
    position: absolute;
    top: -120px;
    right: -120px;
    width: 550px;
    height: 550px;
    background: radial-gradient(circle, rgba(123, 17, 19, 0.08) 0%, transparent 65%);
    pointer-events: none;
    border-radius: 50%;
}

#loginScreen::after {
    content: '';
    position: absolute;
    bottom: -100px;
    left: -100px;
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.08) 0%, transparent 65%);
    pointer-events: none;
    border-radius: 50%;
}

/* Allow body scroll when login screen is active on mobile */
@media (max-width: 768px) {
    body:has(#loginScreen.active) {
        overflow: auto;
        height: auto;
    }

    #loginScreen {
        min-height: 100vh;
        height: auto;
        display: block;
        padding: 20px;
    }
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 16px;
    position: relative;
    z-index: 2;
    margin: auto;
}

.login-box {
    padding: 28px 28px 22px;
    border-radius: 20px;
    text-align: center;
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    box-shadow: 0 20px 45px -10px rgba(123, 17, 19, 0.12),
                0 0 0 1px rgba(226, 232, 240, 0.85);
}

.login-header h1 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
    margin: 6px 0 2px;
    line-height: 1.2;
}

.portal-logo {
    width: 70px;
    height: 70px;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.12));
}

.login-header p {
    color: var(--secondary);
    margin-bottom: 16px;
    font-size: 0.88rem;
    font-weight: 600;
}

.input-group {
    text-align: left;
    margin-bottom: 13px;
    position: relative;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1.5px solid #CBD5E1;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    background: #F8FAFC;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(123, 17, 19, 0.1);
}

.input-group i {
    position: absolute;
    left: 13px;
    top: 36px;
    color: #94A3B8;
    font-size: 13px;
}

.btn-primary {
    width: 100%;
    padding: 11px 20px;
    background: #7B1113;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    margin-top: 12px;
    box-shadow: 0 4px 12px rgba(123, 17, 19, 0.25);
}

.btn-primary:hover {
    background: #630C0F;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(123, 17, 19, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(123, 17, 19, 0.2);
}

.error-msg {
    color: var(--danger);
    font-size: 0.9rem;
    margin-top: 15px;
    min-height: 20px;
}

/* Menu Toggle - Hidden on Desktop */
.menu-toggle {
    display: none;
}

.sidebar-overlay {
    display: none;
}

/* Main App Layout */
#portalApp {
    display: flex;
    background: #f1f5f9;
}

.sidebar {
    width: 280px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-bottom: 30px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.student-avatar {
    width: 50px;
    height: 50px;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.student-info h3 {
    font-size: 1rem;
    font-weight: 600;
}

.student-info p {
    font-size: 0.8rem;
    color: var(--secondary);
}

.sidebar-nav {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 5px;
}

/* Custom Scrollbar for Sidebar */
.sidebar::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    text-decoration: none;
    color: var(--secondary);
    border-radius: 10px;
    margin-bottom: 5px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(123, 17, 19, 0.06);
    color: var(--primary);
}

.nav-item.active {
    background: linear-gradient(135deg, #7B1113 0%, #56090D 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(123, 17, 19, 0.35);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.btn-logout {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    color: var(--secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #fee2e2;
    color: var(--danger);
    border-color: #fecaca;
}

.main-content {
    flex-grow: 1;
    margin-left: 280px;
    min-height: 100vh;
    padding: 20px 40px;
}

.top-nav {
    padding: 15px 30px;
    border-radius: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.badge {
    padding: 6px 15px;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-left: 10px;
}

/* Content Sections */
.content-section {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.content-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-banner {
    padding: 40px;
    border-radius: 20px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, white 0%, #f1f5f9 100%);
}

.banner-text h1 {
    font-size: 2.2rem;
    color: var(--primary);
}

.banner-img i {
    font-size: 5rem;
    color: rgba(30, 79, 156, 0.1);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    padding: 25px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
}

.icon-box {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.icon-box.blue {
    background: #dbeafe;
    color: #1e40af;
}

.icon-box.green {
    background: #dcfce7;
    color: #166534;
}

.icon-box.orange {
    background: #ffedd5;
    color: #9a3412;
}

.stat-card h3 {
    font-size: 0.9rem;
    color: var(--secondary);
    margin-bottom: 5px;
}

.stat-card p {
    font-size: 1.5rem;
    font-weight: 700;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-header button {
    padding: 5px 12px;
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.card-header button:hover {
    background: var(--primary);
    color: white;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid #f1f5f9;
    color: var(--secondary);
    font-size: 0.85rem;
    font-weight: 600;
}

td {
    padding: 12px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
}

tr:last-child td {
    border-bottom: none;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--secondary);
}

/* Timeline */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.timeline-item {
    display: flex;
    gap: 15px;
    position: relative;
    padding-bottom: 15px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 20px;
    bottom: 0;
    width: 2px;
    background: #e2e8f0;
}

.timeline-item:last-child::before {
    display: none;
}

.dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #1e4f9c;
    border: 3px solid white;
    z-index: 1;
}

.timeline-details p {
    font-size: 0.9rem;
    font-weight: 500;
}

.timeline-details span {
    font-size: 0.75rem;
    color: var(--secondary);
}

/* Profile Section */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
}

.profile-card {
    padding: 40px;
    border-radius: 20px;
    text-align: center;
}

.profile-avatar {
    font-size: 5rem;
    color: var(--primary);
    margin-bottom: 20px;
}

.lrn-tag {
    display: inline-block;
    padding: 5px 15px;
    background: #f1f5f9;
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--secondary);
    margin-top: 10px;
}

.profile-details {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid #e2e8f0;
    text-align: left;
    display: grid;
    gap: 15px;
}

.detail-item label {
    font-size: 0.75rem;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.info-card {
    padding: 30px;
    border-radius: 20px;
}

.info-card h3 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f5f9;
}

.info-card h3:not(:first-child) {
    margin-top: 40px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.info-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--secondary);
    margin-bottom: 5px;
}

.info-item span {
    font-weight: 500;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
    }

    .sidebar span,
    .student-info,
    .sidebar-header,
    .btn-logout span {
        display: none;
    }

    .main-content {
        margin-left: 80px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {

    /* Sliding Sidebar for Mobile */
    .sidebar {
        width: 280px;
        height: 100vh;
        flex-direction: column;
        position: fixed;
        left: -280px;
        top: 0;
        bottom: auto;
        padding: 20px;
        border-radius: 0;
        border-right: 1px solid #e2e8f0;
        transition: left 0.3s ease;
        z-index: 2000;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-header {
        display: flex;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 5px;
    }

    .nav-item {
        flex-direction: row;
        padding: 12px 15px;
        gap: 12px;
        font-size: 0.95rem;
        margin-bottom: 5px;
    }

    .nav-item i {
        font-size: 1.2rem;
    }

    .nav-item span {
        display: block !important;
    }

    .sidebar-footer {
        display: block;
    }

    /* Overlay for sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1999;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Hamburger Menu Button */
    .menu-toggle {
        display: block;
        position: fixed;
        top: 20px;
        left: 20px;
        z-index: 2001;
        background: var(--primary);
        color: white;
        border: none;
        width: 45px;
        height: 45px;
        border-radius: 12px;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(30, 79, 156, 0.3);
        transition: all 0.3s;
    }

    .menu-toggle:active {
        transform: scale(0.95);
    }

    .menu-toggle i {
        font-size: 1.2rem;
    }

    .main-content {
        margin-left: 0;
        margin-bottom: 0;
        padding: 70px 15px 15px 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .top-nav {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .academic-info {
        margin-left: -10px;
    }

    .banner-text h1 {
        font-size: 1.5rem;
    }

    .banner-img {
        display: none;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .login-container {
        max-width: 100%;
        padding: 0 15px;
        margin: 0 auto;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
    }

    .login-box {
        padding: 25px 20px;
        width: 100%;
        max-width: 400px;
    }

    .portal-logo {
        width: 70px;
        height: 70px;
    }

    .login-header h1 {
        font-size: 1.4rem;
    }

    .login-header p {
        font-size: 0.85rem;
        margin-bottom: 15px;
    }

    .input-group {
        margin-bottom: 12px;
    }

    .btn-primary {
        margin-top: 15px;
        margin-bottom: 15px;
        padding: 14px;
        font-size: 1rem;
    }

    .login-footer {
        margin-top: 15px;
        padding-top: 15px;
        font-size: 0.8rem;
    }

    .error-msg {
        margin-top: 10px;
        min-height: 25px;
    }
}

/* ==================== SSLG ELECTION STYLES ==================== */

.election-container {
    max-width: 1000px;
}

.election-header {
    padding: 25px 30px;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    background: linear-gradient(135deg, white 0%, #f1f5f9 100%);
}

.election-info h2 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 5px;
}

.election-info p {
    color: var(--secondary);
    font-size: 0.9rem;
}

.election-meta {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.election-meta .badge {
    background: var(--success);
    color: white;
}

/* Already Voted Message */
.already-voted {
    padding: 50px;
    border-radius: 16px;
    text-align: center;
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
}

.already-voted i {
    font-size: 4rem;
    color: var(--success);
    margin-bottom: 20px;
}

.already-voted h3 {
    color: #166534;
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.already-voted p {
    color: #15803d;
    margin-bottom: 25px;
}

/* No Election Message */
.no-election {
    padding: 60px;
    border-radius: 16px;
    text-align: center;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.no-election i {
    font-size: 4rem;
    color: var(--secondary);
    margin-bottom: 20px;
}

.no-election h3 {
    color: var(--text-main);
    margin-bottom: 10px;
}

.no-election p {
    color: var(--secondary);
}

/* Voting Instructions */
.voting-instructions {
    padding: 15px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    background: #dbeafe;
    border: 1px solid #93c5fd;
}

.voting-instructions i {
    font-size: 1.5rem;
    color: #2563eb;
}

.voting-instructions p {
    color: #1e40af;
    font-size: 0.9rem;
}

/* Position Cards */
.position-card {
    background: white;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

.position-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f1f5f9;
}

.position-header h3 {
    font-size: 1.2rem;
    color: var(--primary);
}

.position-header .vote-count {
    font-size: 0.85rem;
    color: var(--secondary);
    background: #f1f5f9;
    padding: 5px 12px;
    border-radius: 50px;
}

/* Candidate List */
.candidates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.candidate-option {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.candidate-option:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(30, 79, 156, 0.15);
}

.candidate-option.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
}

.candidate-option.selected .candidate-check {
    display: flex;
}

.candidate-check {
    display: none;
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
}

.candidate-option {
    position: relative;
}

.candidate-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 15px;
    overflow: hidden;
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.candidate-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.candidate-photo i {
    font-size: 3rem;
    color: #94a3b8;
}

.candidate-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 5px;
}

.candidate-partylist {
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 5px;
}

.candidate-motto {
    font-size: 0.8rem;
    color: var(--secondary);
    font-style: italic;
}

/* Vote Submit Section */
.vote-submit-section {
    padding: 25px;
    border-radius: 16px;
    text-align: center;
    margin-top: 30px;
    background: linear-gradient(135deg, white 0%, #f8fafc 100%);
}

.btn-large {
    padding: 15px 40px;
    font-size: 1.1rem;
}

.warning-text {
    margin-top: 15px;
    font-size: 0.85rem;
    color: var(--warning);
}

.warning-text i {
    margin-right: 5px;
}

/* Election Results View */
.results-view {
    animation: fadeIn 0.4s ease-out;
}

.results-header {
    padding: 20px 25px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.results-header h3 {
    color: var(--primary);
}

.result-position-card {
    background: white;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

.result-position-header {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-candidates-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-candidate-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    border-radius: 10px;
    background: #f8fafc;
}

.result-candidate-item.winner {
    background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
    border: 1px solid #a7f3d0;
}

.result-candidate-item.winner::before {
    content: '🏆';
    font-size: 1.2rem;
}

.result-rank {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85rem;
}

.result-candidate-item.winner .result-rank {
    background: #f59e0b;
}

.result-candidate-photo {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    overflow: hidden;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-candidate-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-candidate-photo i {
    font-size: 1.8rem;
    color: #94a3b8;
}

.result-candidate-info {
    flex: 1;
}

.result-candidate-info .name {
    font-weight: 600;
    font-size: 0.95rem;
}

.result-candidate-info .partylist {
    font-size: 0.8rem;
    color: var(--primary);
}

.result-votes {
    text-align: right;
}

.result-votes .count {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary);
}

.result-votes .percent {
    font-size: 0.8rem;
    color: var(--secondary);
}

.result-bar {
    width: 120px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.result-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #0284c7);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.result-candidate-item.winner .result-bar-fill {
    background: linear-gradient(90deg, #10b981, #059669);
}

.btn-secondary {
    padding: 10px 20px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    color: var(--secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f8fafc;
    color: var(--primary);
    border-color: var(--primary);
}

/* Responsive Election Styles */
@media (max-width: 768px) {
    .election-header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .candidates-grid {
        grid-template-columns: 1fr 1fr;
    }

    .result-candidate-item {
        flex-wrap: wrap;
    }

    .result-bar {
        width: 100%;
        margin-top: 10px;
    }
}

/* ==================== iOS & MOBILE COMPATIBILITY OVERHAUL ==================== */

/* iOS Safe Area Support (notch, home bar) */
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* Prevent iOS rubber-band overscroll on body but allow scrolling inside panels */
html {
    height: -webkit-fill-available;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-x pan-y;
}

/* Fix input zoom on iOS (font-size must be >= 16px to prevent auto-zoom) */
input, select, textarea {
    font-size: 16px !important;
    border-radius: 10px;
    -webkit-appearance: none;
    appearance: none;
}

/* Fix buttons and links for touch */
button, .btn-primary, .btn-secondary, .nav-item, .option-item, a {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
}

/* Minimum tap target size (44px Apple HIG standard) */
.btn-primary, .btn-secondary, .btn-logout, .menu-toggle, .nav-item {
    min-height: 44px;
}

/* Portal App full screen on mobile */
#portalApp {
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* Fix sidebar scrolling on iOS */
.sidebar {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav {
    -webkit-overflow-scrolling: touch;
}

/* Main content safe area padding for iPhone notch/home bar */
.main-content {
    padding-bottom: calc(20px + var(--safe-bottom));
    padding-left: calc(var(--safe-left));
    padding-right: calc(var(--safe-right));
}

/* Menu toggle position accounts for iOS status bar */
.menu-toggle {
    top: calc(15px + var(--safe-top));
    left: calc(15px + var(--safe-left));
}

/* Fix glass blur on iOS (use solid fallback if blur unsupported) */
@supports not ((-webkit-backdrop-filter: blur(10px)) or (backdrop-filter: blur(10px))) {
    .glass {
        background: rgba(255, 255, 255, 0.97) !important;
    }
}

/* ---- Small Phone (max 480px / iPhone SE / iPhone 12 mini) ---- */
@media (max-width: 480px) {
    .main-content {
        padding: calc(65px + var(--safe-top)) 12px calc(20px + var(--safe-bottom)) 12px;
    }

    .menu-toggle {
        width: 42px;
        height: 42px;
        top: calc(12px + var(--safe-top));
        left: calc(12px + var(--safe-left));
    }

    .welcome-banner {
        padding: 20px;
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .banner-text h1 {
        font-size: 1.3rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 15px;
        gap: 12px;
    }

    .icon-box {
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
        flex-shrink: 0;
    }

    .stat-card p {
        font-size: 1.3rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .top-nav {
        padding: 12px 15px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .top-nav .section-title h2 {
        font-size: 1.1rem;
    }

    .badge {
        font-size: 0.75rem;
        padding: 4px 10px;
    }

    /* Table horizontal scroll on small screens */
    .table-container, table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    th, td {
        padding: 10px 8px;
        font-size: 0.82rem;
    }

    /* Profile */
    .profile-grid {
        grid-template-columns: 1fr;
    }

    .profile-card {
        padding: 20px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    /* Login box on very small phones */
    .login-box {
        padding: 20px 15px;
        border-radius: 18px;
    }

    .login-header h1 {
        font-size: 1.25rem;
    }

    .portal-logo {
        width: 60px;
        height: 60px;
    }
}

/* ---- Standard Mobile (481px - 768px / iPhone 12, 14, 15, Android) ---- */
@media (min-width: 481px) and (max-width: 768px) {
    .main-content {
        padding: calc(70px + var(--safe-top)) 15px calc(20px + var(--safe-bottom)) 15px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- Exam Interface Mobile Fixes ---- */
@media (max-width: 768px) {
    /* Exam timer stays visible at top */
    .exam-timer {
        position: sticky;
        top: calc(var(--safe-top));
        z-index: 200;
        font-size: 0.9rem;
        padding: 8px 16px;
    }

    /* Question cards full width & text copy prevention */
    .question-card, .question-card * {
        padding: 18px;
        border-radius: 12px;
        margin-bottom: 15px;
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
    }

    /* Larger touch-friendly option items */
    .option-item {
        padding: 14px 12px;
        min-height: 52px;
        gap: 10px;
    }

    .option-item .option-label {
        font-size: 0.95rem;
        line-height: 1.4;
    }

    /* Navigation buttons full width on mobile */
    .exam-navigation {
        flex-wrap: wrap;
        gap: 10px;
    }

    .exam-navigation button {
        flex: 1;
        min-width: 120px;
        padding: 14px;
        font-size: 0.95rem;
    }

    /* Math scratchpad modal full screen on mobile */
    #mathScratchpadModal, #mathCalcModal {
        position: fixed !important;
        top: var(--safe-top) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: var(--safe-bottom) !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        z-index: 99999 !important;
        transform: none !important;
    }

    #scratchpadCanvas {
        width: 100% !important;
        height: 300px !important;
    }
}

/* ---- LMS / Remediation Room mobile fixes ---- */
@media (max-width: 768px) {
    /* Remedial room: stack panels vertically */
    #studentRemedialRoomView > div {
        flex-direction: column !important;
        gap: 15px;
    }

    /* Activity accordion padding */
    .activity-step-body, #activitiesAccordion > div {
        padding: 12px !important;
    }

    /* LMS tabs scrollable on mobile */
    .lms-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        padding-bottom: 5px;
    }

    .lms-tabs button {
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 44px;
    }

    /* Grid cards single column */
    #studentModularList,
    #studentMaterialsList,
    #studentRemedialList,
    #studentSubjectFoldersGrid {
        grid-template-columns: 1fr !important;
    }

    /* Learner Record tables */
    .lr-tables-grid {
        grid-template-columns: 1fr !important;
    }

    #stLRDocumentContainer {
        padding: 15px !important;
    }

    /* Grades signature canvas touch support */
    #gradesSignCanvas {
        touch-action: none;
        width: 100% !important;
        height: 160px !important;
    }
}

/* ---- Sidebar Nav Items: ensure text visible on mobile ---- */
@media (max-width: 768px) {
    .nav-item {
        padding: 14px 18px;
        font-size: 1rem;
        min-height: 50px;
        border-radius: 10px;
    }

    .nav-item i {
        font-size: 1.25rem;
        width: 24px;
        flex-shrink: 0;
    }

    .student-info h3 {
        font-size: 0.95rem;
        line-height: 1.3;
    }

    .student-info p {
        font-size: 0.78rem;
    }

    .btn-logout {
        min-height: 48px;
        font-size: 0.95rem;
    }
}

/* ---- Communication Section Mobile ---- */
@media (max-width: 768px) {
    .message-list, .message-detail {
        font-size: 0.9rem;
    }

    .message-compose textarea {
        font-size: 16px !important;
        min-height: 100px;
    }
}

/* Landscape phone fix: reduce top spacing */
@media (max-height: 500px) and (orientation: landscape) {
    .main-content {
        padding-top: calc(55px + var(--safe-top));
    }

    .menu-toggle {
        top: calc(10px + var(--safe-top));
    }

    .question-card {
        padding: 12px;
    }

    .exam-timer {
        font-size: 0.82rem;
        padding: 6px 12px;
    }
}

/* ==================== IPHONE & MOBILE FULL SCROLL & LAYOUT SCALING ==================== */
@media (max-width: 768px) {
    /* Fix screen container: allow smooth natural touch scroll on iOS / Android */
    #portalApp.screen.active {
        display: block !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        height: -webkit-fill-available !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        box-sizing: border-box !important;
    }

    /* Main content container scaling for mobile viewports */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        min-height: 100% !important;
        padding: calc(55px + var(--safe-top)) 10px calc(60px + var(--safe-bottom)) 10px !important;
        overflow-y: visible !important;
    }

    /* Content Area & Sections: ensure overflow visible so user can scroll down */
    .content-area, .content-section, #examsSection {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: visible !important;
    }

    /* Compact Examination List Bar */
    #examsSection > div:first-child {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        margin-bottom: 12px !important;
    }

    #examFolderBreadcrumb {
        font-size: 0.95rem !important;
    }

    .exams-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Exam Header Sticky Full Screen Docking */
    .exam-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
        padding: 10px 14px !important;
        border-radius: 12px !important;
        margin-bottom: 10px !important;
        gap: 8px !important;
        background: rgba(255, 255, 255, 0.96) !important;
        backdrop-filter: blur(15px) !important;
        border: 1px solid rgba(226, 232, 240, 0.9) !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08) !important;
    }

    /* Reading Passage Sticky Docking below Exam Header */
    #examReadingText {
        position: sticky !important;
        top: 55px !important;
        z-index: 950 !important;
        max-height: 220px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        background: #fffde7 !important;
        border-left: 5px solid #fdd835 !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08) !important;
        border-radius: 12px !important;
        margin-bottom: 14px !important;
        padding: 14px 16px !important;
    }

    /* Mobile Anti-Screenshot DRM Protection & Touch Callout Block */
    body.exam-mode,
    body.exam-mode * {
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        -khtml-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
    }

    /* Anti-Screenshot Blackout Blur */
    body.blur-exam #examInterface,
    body.blur-exam #portalApp {
        filter: blur(60px) brightness(0) !important;
        opacity: 0 !important;
        background: #000000 !important;
        pointer-events: none !important;
    }

    /* Print Protection */
    @media print {
        html, body, #portalApp, #examInterface {
            display: none !important;
            visibility: hidden !important;
        }
    }

    .exam-header h2 {
        font-size: 1.05rem !important;
        margin-bottom: 2px !important;
    }

    .exam-header p {
        font-size: 0.8rem !important;
    }

    .exam-timer {
        font-size: 0.85rem !important;
        padding: 6px 12px !important;
        border-radius: 20px !important;
    }

    /* Question Card Mobile Sizing */
    .question-card {
        padding: 14px 14px 18px 14px !important;
        border-radius: 12px !important;
        min-height: auto !important;
        margin-bottom: 15px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05) !important;
    }

    /* Question text size scaled for mobile screens */
    .question-card > div:nth-child(2) {
        font-size: 1.05rem !important;
        margin: 8px 0 14px 0 !important;
        line-height: 1.45 !important;
    }

    /* Options List Mobile Sizing */
    .options-list {
        gap: 8px !important;
        margin-top: 12px !important;
    }

    .option-item {
        padding: 12px 10px !important;
        min-height: 46px !important;
        border-radius: 10px !important;
    }

    .option-item .option-label {
        font-size: 0.9rem !important;
        line-height: 1.35 !important;
    }

    /* Sticky Bottom Floating Exam Navigation Dock for Mobile & iPhone */
    .exam-navigation {
        position: sticky !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-top: 15px !important;
        margin-bottom: 0 !important;
        margin-left: -8px !important;
        margin-right: -8px !important;
        padding: 10px 14px calc(12px + env(safe-area-inset-bottom)) 14px !important;
        background: rgba(255, 255, 255, 0.98) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border-top: 1px solid rgba(226, 232, 240, 0.95) !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12) !important;
        gap: 10px !important;
    }

    .exam-navigation button {
        height: 46px !important;
        flex: 1 !important;
        min-width: 0 !important;
        padding: 10px 12px !important;
        font-size: 0.92rem !important;
        font-weight: 700 !important;
        border-radius: 12px !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
    }
}

/* ==================== 4-SLOT ATTENDANCE & KPI STYLING ==================== */
.attendance-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.attendance-kpi-grid .kpi-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.attendance-kpi-grid .kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.attendance-container {
    background: #ffffff;
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    width: 100%;
    box-sizing: border-box;
}

.attendance-container .table-container {
    width: 100% !important;
    overflow-x: hidden !important;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

#fullAttendanceTable {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

#fullAttendanceTable th {
    font-size: 0.82rem;
    letter-spacing: 0.2px;
}

#fullAttendanceTable td {
    vertical-align: middle;
}

@media (max-width: 768px) {
    .attendance-kpi-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .attendance-container {
        padding: 14px 12px;
    }

    .attendance-container .table-container {
        overflow-x: auto !important;
    }

    #fullAttendanceTable {
        min-width: 500px;
    }
}

@media (max-width: 480px) {
    .attendance-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

