* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
body { background: linear-gradient(135deg, #50C878, #FFA500, #C0C0C0); background-attachment: fixed; height: 100vh; overflow: hidden; color: #333; }

.glass-card { background: rgba(255, 255, 255, 0.25); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); border: 1px solid rgba(255, 255, 255, 0.4); box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2); border-radius: 20px; padding: 2.5rem; }
.glass-panel { background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.5); box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1); }
.view-section { display: none; height: 100vh; width: 100vw; }
.view-section.active { display: flex; }

/* Landing Page */
#landing-page { flex-direction: column; justify-content: center; align-items: center; }
.center-content { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 400px; }
.logo-title { font-size: 3rem; color: #fff; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); margin-bottom: 10px; }
.button-group { margin-top: 2rem; display: flex; gap: 1rem; justify-content: center; width: 100%;}

/* Modals & Forms */
.modal { display: none; position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.4); justify-content: center; align-items: center; }
.modal-content { width: 350px; position: relative; text-align: center; }
.close { position: absolute; top: 15px; right: 20px; font-size: 1.5rem; cursor: pointer; color: #555; }
.settings-form { margin-top: 20px; text-align: left; }
.settings-form label { font-size: 0.8rem; font-weight: bold; color: #555; margin-bottom: 2px; display: block;}
input, select { width: 100%; padding: 8px; margin: 5px 0 10px 0; border: 1px solid #ccc; border-radius: 5px; background: rgba(255,255,255,0.9); }
.split-inputs { display: flex; gap: 10px; }
.split-inputs > * { flex: 1; }

/* Buttons */
.btn { padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer; font-weight: bold; transition: transform 0.2s, opacity 0.2s; }
.btn:hover { opacity: 0.9; transform: translateY(-2px); }
.btn-primary { background: #50C878; color: white; }
.btn-secondary { background: #FFA500; color: white; }
.btn-danger { background: #ff4d4d; color: white; }
.btn-sm { padding: 6px 10px; font-size: 0.85rem; }
.w-100 { width: 100%; margin-top: 10px; padding: 12px;}
.combo-btn { display: flex; gap: 2px; }
.combo-btn .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.combo-btn .btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 6px 8px;}

/* Sidebar */
#app-page { flex-direction: row; padding: 10px; gap: 10px; }
.sidebar { width: 220px; border-radius: 12px; display: flex; flex-direction: column; transition: width 0.3s; position: relative; overflow: hidden; }
.sidebar-sticky-top { background: #50C878; padding: 15px; position: sticky; top: 0; z-index: 10; }
.logo-container { display: flex; justify-content: space-between; align-items: center; color: white; margin-bottom: 10px;}
.toggle-btn { background: none; border: none; color: white; font-size: 1.2rem; cursor: pointer; padding: 5px;}

/* Collapsed State Logic */
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed span, .sidebar.collapsed h3, .sidebar.collapsed .search-box, .sidebar.collapsed .sidebar-brand { display: none; }
.sidebar.collapsed .logo-container { justify-content: center; } /* Centers toggle button */

.search-box { position: relative; }
.search-icon { position: absolute; left: 10px; top: 12px; color: #888; font-size: 0.9rem;}
.search-box input { padding-left: 30px; margin: 0; width: 100%; border: none;}
.sidebar-scrollable { flex: 1; overflow-y: auto; padding: 10px; }
.nav-section h3 { font-size: 0.8rem; color: #666; margin-bottom: 10px; text-transform: uppercase; padding-left: 5px;}
.class-list, .settings ul { list-style: none; }
.class-list li, .settings li { padding: 10px; cursor: pointer; border-radius: 5px; margin-bottom: 2px; display: flex; align-items: center; gap: 10px; font-size: 0.85rem;}
.class-list li i, .settings li i { color: #50C878; width: 15px; text-align: center;}
.class-list li:hover, .settings li:hover { background: rgba(80, 200, 120, 0.2); }
.class-list li.active-tab { background: #50C878; color: white; }
.class-list li.active-tab i { color: white; }
.sidebar-sticky-bottom { position: sticky; bottom: 0; background: rgba(255,255,255,0.95); border-top: 1px solid #ddd; padding: 10px; z-index: 10; }
.settings li.danger:hover { background: rgba(255, 0, 0, 0.1); color: red; }

/* Main Content */
.main-content { flex: 1; border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
.header-actions { padding: 15px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #ddd; background: rgba(255,255,255,0.5); }
.status-indicators { display: flex; gap: 10px; align-items: center; font-size: 0.85rem; font-weight: bold;}
.badge { background: #eee; padding: 5px 10px; border-radius: 15px; color: #555; }
.focused-student { color: black; font-style: normal; text-transform: uppercase; margin-left: 10px;}
.mobile-only { display: none; color: #333;}
.action-buttons { display: flex; gap: 8px; }

/* Spreadsheet (Solid Grids) */
.spreadsheet-container { flex: 1; overflow: auto; padding: 15px; }
table { border-collapse: collapse; background: white; white-space: nowrap; width: max-content; border: 2px solid #555;}
th, td { border: 1px solid #777; padding: 0; height: 35px; text-align: center; }
th { background: #f0f0f0; font-size: 0.8rem; padding: 5px; }
.col-num { min-width: 35px; background: #f0f0f0; color: #555; }
.col-action { min-width: 35px; }
.col-name { min-width: 250px; max-width: 250px; text-align: left; padding-left: 5px; position: sticky; left: 0; background: #fff; z-index: 2;}
th.col-name { background: #f0f0f0; z-index: 3;}
.score-cell { min-width: 45px; max-width: 45px; } 
.subject-head { background: #e0f2f1; border-bottom: 1px solid #777; }
.sub-head { background: #f9f9f9; font-size: 0.7rem; color: #444; }

/* End Columns */
.col-fixed { min-width: 70px; max-width: 70px; background: #fff3e0;}
td.col-fixed input { background: #fafafa; font-size: 0.75rem;}
td input, td select { width: 100%; height: 100%; border: none; outline: none; padding: 0 5px; box-sizing: border-box; font-size: 0.85rem; text-align: center; background: transparent;}

/* Uppercase Student Names */
.name-col input { text-align: left; text-transform: uppercase; color: black; font-weight: 500;}
td input:focus { box-shadow: inset 0 0 0 2px #50C878; z-index: 5; position: relative;}
.del-btn { background: none; border: none; color: #ff4d4d; cursor: pointer; font-size: 0.9rem; width: 100%; height: 100%; }
.del-btn:hover { background: #ffe6e6; }
.hidden-col, .hidden-row { display: none !important; }

/* Emoji Avatar Upload Style */
.avatar-label { cursor: pointer; display: flex; justify-content: center; align-items: center; width: 100%; height: 100%; }
.avatar-emoji { font-size: 1.2rem; background: #eee; border-radius: 50%; width: 25px; height: 25px; display: inline-block; line-height: 25px; text-align: center;}
.avatar-preview { width: 25px; height: 25px; border-radius: 50%; object-fit: cover; }

/* A4 Print Setup (Headers/Footers removed, Border added, Images fixed) */
#print-area { display: none; }
@media print {
    body * { visibility: hidden; }
    #print-area, #print-area * { visibility: visible; }
    #print-area { position: absolute; left: 0; top: 0; width: 100%; }

    @page { margin: 0; }
    
    .print-page {
        visibility: visible;
        break-after: page;
        padding: 1.5cm;
        height: 297mm; /* Standard A4 Height */
        display: flex;
        flex-direction: column;
        color: black;
        box-sizing: border-box;
    }

    /* 1. School Name (Top & Centered) */
    .print-header-name {
        text-align: center;
        font-size: 24pt;
        font-weight: bold;
        margin-bottom: 15px;
        text-transform: uppercase;
    }

    /* 2 & 3. The Strict Logo and Center Text Row */
    .print-identity-row {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 20px;
        width: 100%;
    }

    /* The strictly locked 165x165 Image Frames */
    .img-frame {
        width: 165px;
        height: 165px;
        min-width: 165px; /* STOPS TEXT FROM CRUSHING IT */
        max-width: 165px; 
        flex-shrink: 0; /* Refuses to resize */
        border: 2px solid #000;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    /* Magic fill & fit perfectly */
    .img-frame img {
        width: 100%;
        height: 100%;
        object-fit: cover; /* Fills square perfectly, cropping overflow instead of stretching */
        object-position: center;
    }

    /* Center Text Area */
    .center-info-box {
        flex: 1; /* Takes up all space between the two logos */
        text-align: center;
        padding: 0 15px;
        overflow: hidden;
    }

    .center-info-box h2 {
        margin: 0;
        font-size: 16pt;
        text-decoration: underline;
    }

    .center-details {
        margin-top: 15px;
    }

    .center-details p {
        margin: 4px 0;
        font-size: 11pt;
    }

    /* 4. Student Name & Class Row */
    .student-info-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 10px;
        font-size: 12pt;
        border-bottom: 2px solid #000;
        padding-bottom: 5px;
    }

    /* The Scores Table */
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 15px;
    }
    .print-table th, .print-table td {
        border: 1.5px solid black !important;
        padding: 8px;
        text-align: center;
    }

    /* 5. Footer Summary Row (Left, Mid, Right) */
    .footer-summary-row {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        font-size: 12pt;
        margin-bottom: 20px;
        padding: 10px;
        border: 1.5px solid black;
        background: #fafafa;
    }
    .summary-left { text-align: left; }
    .summary-center { text-align: center; }
    .summary-right { text-align: right; }

    /* The Signature Box at the Bottom Right */
    .signature-section {
        display: flex;
        flex-direction: column;
        align-items: flex-end; /* Pushes it to the right */
    }

    .signature-frame {
        width: 250px;
        height: 80px;
        min-width: 250px;
        min-height: 80px;
        border: 2px dashed #666; /* Dashed line looks professional for signatures */
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }
    
    .signature-frame img {
        width: 100%;
        height: 100%;
        /* 'contain' is better for signatures so the edges of the pen strokes aren't cut off */
        object-fit: contain; 
    }

    .sig-label {
        font-weight: bold;
        margin-top: 5px;
        text-align: center;
        width: 250px;
    }
}
.btn-danger {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

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