/* =====================================================
   HSS Larnoo ID System — app.css
   All application styles in one place
   ===================================================== */

:root {
    --primary-color: #0d2c54;
    --secondary-color: #1a535c;
    --accent-color: #f7b801;
    --edit-color: #0077b6;
    --danger-color: #d90429;
    --success-color: #28a745;
    --light-color: #f4f7fe;
    --dark-color: #333333;
    --white-color: #ffffff;
    --card-width: 380px;
    --card-aspect-ratio: 8.53 / 5.39;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--light-color);
    color: var(--dark-color);
    line-height: 1.6;
    margin: 0;
}

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

/* ---- Buttons ---- */
.btn {
    font-weight: 600; transition: all 0.3s ease; padding: 12px 25px;
    border-radius: 8px; border: none; cursor: pointer; font-size: 16px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background-color: var(--primary-color); color: var(--white-color); }
.btn-primary:hover:not(:disabled) { background-color: #123e7a; transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.btn:disabled { background-color: #a9a9a9; cursor: not-allowed; }
.btn-success { background-color: var(--success-color); color: #fff; }
.btn-success:hover { background-color: #218838; transform: translateY(-2px); }
.btn-warning { background-color: var(--accent-color); color: var(--dark-color); }
.btn-warning:hover { background-color: #e5a800; transform: translateY(-2px); }
.btn-info { background-color: #17a2b8; color: #fff; }
.btn-info:hover { background-color: #138496; transform: translateY(-2px); }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ---- Typography ---- */
.section-title {
    font-family: 'Poppins', sans-serif; font-weight: 700; color: var(--primary-color);
    margin-top: 0; margin-bottom: 25px;
    border-bottom: 3px solid var(--accent-color); padding-bottom: 10px;
}

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 8px;
    box-sizing: border-box; font-family: 'Montserrat', sans-serif; font-size: 15px;
    transition: border-color 0.3s, box-shadow 0.3s; background-color: #fff;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none; border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 44, 84, 0.1);
}
.custom-select-wrapper { position: relative; }
.custom-select-wrapper::after {
    content: '\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900;
    position: absolute; right: 15px; top: 50%; transform: translateY(-50%); pointer-events: none;
}
.form-group select { appearance: none; -webkit-appearance: none; padding-right: 40px; }

/* ---- Header & Nav ---- */
#app-header {
    background-color: var(--white-color); padding: 15px 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); display: flex;
    justify-content: space-between; align-items: center;
    position: sticky; top: 0; z-index: 1000; flex-wrap: wrap; gap: 10px;
}
#app-header h1 { font-family: 'Poppins', sans-serif; color: var(--primary-color); font-size: 24px; margin: 0; }
#app-header nav { display: flex; flex-wrap: wrap; }
#app-header nav a {
    margin-left: 20px; text-decoration: none; color: var(--primary-color);
    font-weight: 600; cursor: pointer; padding: 5px 10px;
    border-radius: 5px; transition: background-color 0.3s;
}
#app-header nav a:hover { background-color: #f0f0f0; }
#app-header nav a.active { color: var(--accent-color); font-weight: 700; }

/* ---- View System ---- */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.5s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- Layouts ---- */
.main-content { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 40px; width: 100%; }
.form-section, .card-section {
    flex: 1; min-width: 350px; max-width: 550px; background: var(--white-color);
    padding: 30px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.05);
}

/* =====================================================
   ID CARD STYLES
   ===================================================== */
#idCard {
    width: var(--card-width); aspect-ratio: var(--card-aspect-ratio);
    font-family: 'Montserrat', sans-serif; background: #eef2f9; border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15); display: flex; flex-direction: column;
    position: relative; overflow: hidden; margin: 0 auto;
}
#idCard::before, #idCard::after {
    content: ''; position: absolute; border-radius: 50%; opacity: 0.08; z-index: 0;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
}
#idCard::before { width: 150%; height: 150%; bottom: -80%; right: -50%; }
#idCard::after { width: 120%; height: 120%; top: -60%; left: -40%; opacity: 0.1; }
.card-header, .card-body, .card-footer { position: relative; z-index: 1; }
.card-header {
    display: flex; align-items: center; padding: 10px 15px;
    background-color: rgba(255,255,255,0.3); backdrop-filter: blur(5px);
}
.logo { width: 40px; height: 40px; margin-right: 12px; }
.school-title-group { color: var(--primary-color); line-height: 1.2; }
.school-title { font-size: 16px; font-weight: 700; font-family: 'Poppins', sans-serif; margin: 0; }
.school-subtitle { font-size: 12px; font-weight: 500; margin: 0; }
.udise-code { position: absolute; top: 8px; right: 15px; font-size: 8px; font-weight: 600; opacity: 0.8; }
.udise-code span1 { color: red; font-weight: 700; text-decoration: underline; }
.udise-code span { color: var(--primary-color); font-size: 10px; }
.card-session-badge {
    position: absolute; top: 22px; right: 15px;
    font-size: 8px; font-weight: 700;
    background: var(--accent-color); color: var(--primary-color);
    padding: 2px 6px; border-radius: 4px; z-index: 2;
}
.card-body { flex-grow: 1; display: flex; padding: 5px 10px; gap: 10px; align-items: center; }
.card-body .displayPhoto {
    width: 90px; height: 110px; object-fit: cover;
    border: 3px solid var(--white-color); border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2); flex-shrink: 0; background-color: #ddd;
}
.student-details { font-size: 11px; line-height: 1.45; flex-grow: 1; }
.displayName { font-family: 'Poppins', sans-serif; font-size: 13px; font-weight: 650; color: var(--primary-color); margin: 0 0 4px 0; }
.student-details p { margin: 0; }
.student-details .label { font-weight: 600; color: #555; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.card-right-panel { display: flex; flex-direction: column; align-items: center; justify-content: space-between; height: 100%; }
.card-qr-code {
    width: 65px; height: 65px; flex-shrink: 0; background: var(--white-color);
    padding: 4px; border-radius: 6px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-right: 5px; top: 10px; position: relative;
}
.card-qr-code canvas, .card-qr-code img { width: 100% !important; height: 100% !important; }
.signature-section { text-align: center; margin-top: auto; padding-right: 5px; }
.principal-signature { width: 80px; height: auto; margin-bottom: -15px; }
.signature-section p { font-size: 8px; font-weight: 600; margin: 0; color: var(--primary-color); border-top: 1px solid var(--primary-color); padding-top: 2px; }
.card-footer { background: var(--primary-color); color: var(--white-color); text-align: center; padding: 6px; font-size: 9px; margin-top: auto; line-height: 1.3; }
#studentDownloadBtn { display: none; margin-top: 20px; }

/* =====================================================
   ADMIN STYLES
   ===================================================== */
.data-section { width: 100%; margin-top: 20px; background: var(--white-color); padding: 30px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.05); }
.data-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px; }
#searchInput { padding: 10px 15px; border-radius: 8px; border: 1px solid #ccc; width: 300px; font-size: 15px; transition: all 0.3s; }
#searchInput:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(13, 44, 84, 0.1); outline: none; }

/* Admin Tab Styles */
.admin-tabs { display: flex; gap: 10px; margin-bottom: 25px; border-bottom: 2px solid #eee; padding-bottom: 10px; flex-wrap: wrap; }
.admin-tab-btn {
    background: #f8f9fa; border: 1px solid #eee; padding: 12px 20px; border-radius: 8px;
    cursor: pointer; font-weight: 600; color: #666; transition: all 0.3s ease;
    display: flex; align-items: center; gap: 8px;
}
.admin-tab-btn i { font-size: 18px; }
.admin-tab-btn:hover { background: #eef2f9; color: var(--primary-color); }
.admin-tab-btn.active { background: var(--primary-color); color: #fff; border-color: var(--primary-color); box-shadow: 0 4px 12px rgba(13, 44, 84, 0.2); }

.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; animation: fadeIn 0.4s; }

.table-container { overflow-x: auto; margin-top: 20px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; }
.data-table th, .data-table td { padding: 12px 15px; text-align: left; vertical-align: middle; }
.data-table thead { background-color: var(--primary-color); color: var(--white-color); }
.data-table th:first-child { border-radius: 8px 0 0 8px; }
.data-table th:last-child { border-radius: 0 8px 8px 0; }
.data-table tbody tr { border-bottom: 1px solid #e0e0e0; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background-color: #f5f8ff; }
.table-photo { width: 45px; height: 45px; border-radius: 50%; object-fit: cover; }
.action-btn { background: none; border: none; cursor: pointer; font-size: 18px; transition: all 0.3s; padding: 5px; }
.view-card-btn { color: #17a2b8; } .edit-card-btn { color: #0077b6; } .delete-card-btn { color: #d90429; }
.action-btn:hover { transform: scale(1.2); }
#login-container { max-width: 400px; margin: 50px auto; padding: 30px; background: var(--white-color); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.1); text-align: center; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 15px; }
.class-filter-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; background: #f8f9fa; padding: 10px; border-radius: 10px; }
.class-filter-buttons .btn { background-color: #fff; border: 1px solid #ddd; color: var(--dark-color); padding: 6px 12px; font-size: 13px; border-radius: 6px; }
.class-filter-buttons .btn.active { background-color: var(--secondary-color); color: var(--white-color); border-color: var(--secondary-color); }
.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 20px; margin-bottom: 20px; }
.chart-container { position: relative; height: 350px; width: 100%; }
.admin-action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }

/* ---- Edit modal photo ---- */
#editForm .current-photo-preview { margin-bottom: 15px; text-align: center; }
#editForm .current-photo-preview img { max-width: 120px; height: auto; border-radius: 8px; border: 1px solid #eee; }

/* =====================================================
   ATTENDANCE STYLES
   ===================================================== */
#attendance-view .main-content { gap: 20px; flex-direction: column; align-items: stretch; }
#scanner-section { text-align: center; }
#scanner-container {
    border: 2px dashed #ccc; display: inline-block; max-width: 500px;
    width: 100%; padding: 10px; border-radius: 10px; background: #f9f9f9; transition: all 0.3s ease;
}
#scanner-container.scanner-success { border-color: var(--success-color); box-shadow: 0 0 15px rgba(40,167,69,0.5); }
#scanner-container.scanner-error { border-color: var(--danger-color); box-shadow: 0 0 15px rgba(217,4,41,0.5); }
#qr-reader { width: 100%; border-radius: 8px; }
#scan-result { margin-top: 15px; font-size: 1.1em; font-weight: bold; min-height: 50px; padding: 10px; border-radius: 8px; transition: all 0.3s ease; }
.result-success { color: #fff; background-color: var(--success-color); }
.result-error { color: #fff; background-color: var(--danger-color); }
.result-info { color: var(--dark-color); background-color: #e0e0e0; }
.attendance-controls { display: flex; justify-content: space-between; align-items: center; background: #fff; padding: 15px; border-radius: 12px; margin-bottom: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.date-nav { display: flex; align-items: center; gap: 15px; }
.date-nav button { background: none; border: 1px solid #ccc; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; transition: all 0.2s; }
.date-nav button:hover { background: #f0f0f0; border-color: var(--primary-color); }
.date-nav h3 { margin: 0; font-size: 1.2em; color: var(--primary-color); }
#attendance-percentage { font-size: 1.2em; font-weight: 700; color: var(--primary-color); }
.attendance-class-section { margin-bottom: 25px; }
.attendance-class-section h3 { font-family: 'Poppins', sans-serif; color: var(--secondary-color); border-bottom: 2px solid #e8edef; padding-bottom: 8px; }

/* =====================================================
   MODAL STYLES
   ===================================================== */
.modal { display: none; position: fixed; z-index: 1010; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6); backdrop-filter: blur(5px); }
.modal-content { background-color: #fefefe; margin: 5% auto; padding: 30px; border-radius: 12px; border: 1px solid #888; width: 90%; max-width: 550px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; padding-bottom: 15px; margin-bottom: 20px; }
.close-btn { color: #aaa; font-size: 28px; font-weight: bold; cursor: pointer; }
.modal-actions { margin-top: 20px; display: flex; gap: 10px; justify-content: flex-end; }
#print-modal .modal-content { max-width: 420px; }

/* =====================================================
   REPORTS STYLES
   ===================================================== */
.report-search-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.report-search-bar input, .report-search-bar select {
    padding: 10px 15px; border-radius: 8px; border: 1px solid #ccc;
    font-size: 15px; font-family: 'Montserrat', sans-serif;
}
.report-card { background: var(--white-color); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.05); padding: 25px; }
.report-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 15px; margin-top: 20px; }
.stat-box { background: var(--light-color); border-radius: 10px; padding: 18px; text-align: center; border-left: 4px solid var(--primary-color); }
.stat-box.absent { border-left-color: var(--danger-color); }
.stat-box.percent { border-left-color: var(--success-color); }
.stat-box h3 { font-size: 28px; font-weight: 700; color: var(--primary-color); margin: 0; }
.stat-box.absent h3 { color: var(--danger-color); }
.stat-box.percent h3 { color: var(--success-color); }
.stat-box p { font-size: 12px; color: #777; margin: 4px 0 0; }
.report-chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.report-chart-box { background: var(--white-color); border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); padding: 20px; }
.report-chart-box h3 { font-size: 14px; font-weight: 600; color: var(--primary-color); margin: 0 0 15px; }
.report-chart-box .chart-container { height: 220px; }
#report-monthly-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 15px; }
.cal-day { aspect-ratio: 1; border-radius: 6px; font-size: 10px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.cal-present { background: var(--success-color); color: #fff; }
.cal-absent { background: #ffdde1; color: var(--danger-color); }
.cal-holiday { background: #f0f0f0; color: #aaa; }
.cal-future { background: #f9f9f9; color: #ccc; }
.cal-header { font-size: 9px; font-weight: 700; color: #aaa; text-align: center; }
#class-attendance-list { margin-top: 15px; }
.class-att-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.class-att-bar-wrap { flex: 1; background: #eee; border-radius: 20px; height: 10px; }
.class-att-bar { height: 10px; border-radius: 20px; background: var(--secondary-color); transition: width 0.5s; }

/* =====================================================
   BULK IMPORT / EXPORT STYLES
   ===================================================== */
.import-dropzone { border: 2px dashed var(--primary-color); border-radius: 12px; padding: 30px; text-align: center; cursor: pointer; transition: background 0.3s; }
.import-dropzone:hover, .import-dropzone.dragover { background: #e8f0fe; }
.import-dropzone i { font-size: 36px; color: var(--primary-color); margin-bottom: 10px; }
.import-dropzone p { margin: 5px 0; font-size: 14px; color: #555; }
.import-progress { display: none; margin-top: 15px; }
.import-progress-bar-wrap { background: #eee; border-radius: 20px; height: 12px; overflow: hidden; }
.import-progress-bar { height: 12px; border-radius: 20px; background: var(--success-color); width: 0%; transition: width 0.1s; }
.import-log { max-height: 150px; overflow-y: auto; font-size: 12px; margin-top: 10px; background: #f4f7fe; padding: 10px; border-radius: 8px; }
.import-log p { margin: 2px 0; }
.import-log .log-error { color: var(--danger-color); }
.import-log .log-ok { color: var(--success-color); }

/* =====================================================
   PDF PROGRESS OVERLAY
   ===================================================== */
.pdf-progress-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 9999; flex-direction: column; align-items: center; justify-content: center; color: #fff; }
.pdf-progress-overlay.active { display: flex; }
.pdf-progress-box { background: var(--white-color); color: var(--dark-color); border-radius: 16px; padding: 35px 45px; text-align: center; min-width: 300px; }
.pdf-progress-box h3 { color: var(--primary-color); margin: 0 0 15px; }
.pdf-progress-box .pdf-bar-wrap { background: #eee; border-radius: 20px; height: 14px; }
.pdf-progress-box .pdf-bar { height: 14px; border-radius: 20px; background: var(--primary-color); width: 0%; transition: width 0.2s; }
.pdf-progress-box p { font-size: 13px; color: #777; margin-top: 10px; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    #app-header { flex-direction: column; gap: 15px; }
    .main-content { gap: 20px; }
    .card-section { order: -1; }
    .form-section { order: 0; }
    .attendance-controls { flex-direction: column; gap: 15px; }
    #searchInput { width: 100%; }
    .report-chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
    #idCard { transform: scale(0.9); margin-left: -19px; }
    .page-container { padding: 10px; }
    .form-section, .card-section, .data-section { padding: 20px; }
    .date-nav h3 { font-size: 1em; }
}