/* =============================================
   Школьная система — Базовые стили
   ============================================= */

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

:root {
    --primary:   #1a6faf;
    --primary-d: #145a8c;
    --accent:    #f5a623;
    --bg:        #f4f6f9;
    --white:     #ffffff;
    --text:      #333333;
    --muted:     #777777;
    --border:    #dde1e7;
    --danger:    #d9534f;
    --success:   #5cb85c;
    --radius:    6px;
    --shadow:    0 2px 8px rgba(0,0,0,.08);
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Header ---- */
.site-header {
    background: var(--primary);
    color: #fff;
    padding: 0 1rem;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: relative;
}
.header-instructions {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: #fff !important;
    font-size: .9rem;
    opacity: .9;
    border-bottom: 1px dashed rgba(255,255,255,.5);
    white-space: nowrap;
}
.header-instructions:hover { opacity: 1; border-bottom-style: solid; text-decoration: none; }
.site-logo {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    text-decoration: none;
}
.main-nav { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.main-nav a { color: #fff; font-size: .9rem; }
.main-nav a:hover { text-decoration: underline; }
.nav-user { font-size: .85rem; opacity: .8; }
.btn-logout { background: rgba(255,255,255,.2); padding: .2rem .6rem; border-radius: var(--radius); }
.lang-btn { font-size: .8rem; padding: .15rem .4rem; border: 1px solid rgba(255,255,255,.4); border-radius: 3px; }
.lang-btn.active { background: rgba(255,255,255,.25); }
.btn-login { background: #fff; color: var(--primary) !important; padding: .25rem .8rem; border-radius: var(--radius); font-weight: 600; font-size: .85rem; }
.btn-login:hover { background: #e8f0fe; text-decoration: none !important; }

/* ---- Main ---- */
.site-main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

/* ---- Footer ---- */
.site-footer {
    background: var(--primary-d);
    color: rgba(255,255,255,.7);
    text-align: center;
    padding: .8rem 1rem;
    font-size: .85rem;
}

/* ---- Auth ---- */
.auth-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}
.auth-box {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem 2.5rem;
    width: 100%;
    max-width: 380px;
}
.auth-box h1 { margin-bottom: 1.2rem; font-size: 1.3rem; text-align: center; }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: .35rem; font-weight: 600; font-size: .9rem; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .5rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    transition: border-color .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.form-group textarea { min-height: 90px; resize: vertical; }

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: .5rem 1.2rem;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: .95rem;
    font-weight: 600;
    transition: background .2s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; text-align: center; }
.btn-primary:hover { background: var(--primary-d); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .25rem .65rem; font-size: .82rem; }

/* ---- Alerts ---- */
.alert { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.alert-error   { background: #fde8e8; color: #c0392b; border: 1px solid #f5c6cb; }
.alert-success { background: #e8f5e9; color: #27ae60; border: 1px solid #c3e6cb; }

/* ---- Dashboard cards ---- */
.dashboard h1 { margin-bottom: .3rem; }
.welcome { color: var(--muted); margin-bottom: 1.5rem; }
.dashboard-cards { display: flex; flex-wrap: wrap; gap: 1rem; }
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    flex: 1 1 180px;
    font-weight: 600;
    text-align: center;
    color: var(--primary);
    box-shadow: var(--shadow);
    transition: box-shadow .2s;
}
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); text-decoration: none; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { padding: .6rem .9rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .9rem; }
th { background: var(--primary); color: #fff; font-weight: 600; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f0f4f9; }

/* ---- Public home ---- */
.hero { text-align: center; padding: 2rem 0; }
.hero h1 { font-size: 1.8rem; color: var(--primary); }

/* ---- Instructions page ---- */
.instructions-page { max-width: 860px; margin: 0 auto; }
.instructions-page h1 { font-size: 1.6rem; color: var(--primary); margin-bottom: .25rem; }
.instructions-subtitle { color: #666; margin-bottom: 2rem; font-size: .95rem; }
.instructions-section { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem 2rem; margin-bottom: 1.25rem; }
.instructions-section h2 { font-size: 1.1rem; color: var(--primary); margin-bottom: 1rem; border-bottom: 2px solid var(--primary-light, #e8f0fe); padding-bottom: .4rem; }
.instructions-section h3 { font-size: 1rem; margin: 1rem 0 .4rem; color: #333; }
.instructions-section ol, .instructions-section ul { padding-left: 1.4rem; line-height: 1.9; }
.instructions-note { background: #fff8e1; border-left: 4px solid #f9a825; padding: .75rem 1rem; border-radius: 4px; margin-top: 1rem; font-size: .9rem; }
.instructions-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.instructions-table th { background: var(--primary); color: #fff; text-align: left; padding: .5rem .75rem; }
.instructions-table td { padding: .5rem .75rem; border-bottom: 1px solid #eee; vertical-align: top; }
.instructions-table tr:last-child td { border-bottom: none; }
.instructions-table tr:nth-child(even) td { background: #f8f9fa; }
.news-section h2 { margin-bottom: 1rem; }
.news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.news-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.news-card img { width: 100%; height: 180px; object-fit: cover; }
.news-body { padding: 1rem; }
.news-body h3 { margin-bottom: .5rem; font-size: 1rem; }
.news-body time { font-size: .8rem; color: var(--muted); }

/* ---- Error pages ---- */
.error-page { text-align: center; padding: 4rem 0; }
.error-page h1 { font-size: 5rem; color: var(--primary); }

/* ---- Utilities ---- */
.no-data { color: var(--muted); font-style: italic; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; }
.page-header h1 { font-size: 1.3rem; }

/* ---- Filter form ---- */
.filter-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filter-form input, .filter-form select { padding: .4rem .6rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; }

/* ---- Staff/Student forms ---- */
.staff-form { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; }
.form-section { margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.form-section:last-of-type { border-bottom: none; }
.form-section-title { font-size: 1rem; font-weight: 700; color: var(--primary); margin-bottom: .8rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem 1.2rem; }
.form-actions { display: flex; gap: .8rem; padding-top: 1rem; }
.field-error { display: block; color: var(--danger); font-size: .8rem; margin-top: .2rem; }

/* ---- Badges ---- */
.badge-archive { background: #e9ecef; color: #666; font-size: .72rem; padding: .1rem .4rem; border-radius: 3px; margin-left: 4px; vertical-align: middle; }
.actions-cell { white-space: nowrap; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: .4rem; margin-top: 1rem; flex-wrap: wrap; }
.page-link { padding: .3rem .65rem; border: 1px solid var(--border); border-radius: var(--radius); color: var(--primary); font-size: .9rem; }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Modal ---- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: var(--white); border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0,0,0,.2); padding: 1.5rem 2rem; min-width: 320px; max-width: 480px; width: 100%; }
.modal-box h3 { margin-bottom: 1rem; }

/* ---- Teacher profile ---- */
.teacher-profile { display: flex; gap: 1.2rem; align-items: center; background: var(--white); border-radius: var(--radius); padding: 1.2rem 1.5rem; box-shadow: var(--shadow); }
.profile-photo img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; }
.photo-placeholder { width: 80px; height: 80px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; }
.profile-info h2 { margin-bottom: .2rem; }
.card-count { font-size: 2rem; font-weight: 700; color: var(--primary); }

/* ---- Panel ---- */
.panel { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem 1.5rem; }
.form-grid-3 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* ---- Events grid ---- */
.events-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.event-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.event-card img { width: 100%; height: 160px; object-fit: cover; }
.event-body { padding: 1rem; }
.event-body h3 { font-size: .95rem; margin-bottom: .3rem; }
.event-body time { font-size: .8rem; color: var(--muted); display: block; margin-bottom: .4rem; }

/* ---- Attendance ---- */
.attendance-info { background: #e8f0fe; border-radius: var(--radius); padding: .6rem 1rem; font-size: .9rem; }
.att-row.att-absent td { background: #fff8f8; }
.att-row.att-absent td:first-child { border-left: 3px solid var(--danger); }
.reason-input { padding: .3rem .5rem; border: 1px solid var(--border); border-radius: var(--radius); width: 100%; font-size: .88rem; }

/* ---- Analytics / Charts ---- */
.charts-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.chart-box { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; }
.chart-box h3 { font-size: .95rem; margin-bottom: .8rem; }
.pct-badge { padding: .2rem .5rem; border-radius: 3px; font-size: .82rem; font-weight: 600; }
.pct-low  { background: #d4edda; color: #155724; }
.pct-mid  { background: #fff3cd; color: #856404; }
.pct-high { background: #f8d7da; color: #721c24; }

/* ---- Status badges ---- */
.status-badge { display: inline-block; padding: .15rem .5rem; border-radius: 3px; font-size: .8rem; font-weight: 600; }
.badge-pending  { background: #fff3cd; color: #856404; }
.badge-accepted { background: #d4edda; color: #155724; }
.badge-returned { background: #f8d7da; color: #721c24; }

/* ---- Director KPI ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem 1rem; text-align: center; }
.kpi-val { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.kpi-label { font-size: .82rem; color: var(--muted); margin-top: .3rem; }
.reports-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.report-box { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; }
.report-box h3 { font-size: .95rem; margin-bottom: .8rem; }
.report-box table td { padding: .35rem .5rem; }

/* ---- System logs ---- */
.log-badge { display: inline-block; padding: .1rem .45rem; border-radius: 3px; font-size: .78rem; font-weight: 600; }
.log-login  { background: #d4edda; color: #155724; }
.log-logout { background: #e2e3e5; color: #383d41; }
.log-create { background: #cce5ff; color: #004085; }
.log-update { background: #fff3cd; color: #856404; }
.log-delete { background: #f8d7da; color: #721c24; }

/* ---- Profile ---- */
.profile-layout { display: grid; grid-template-columns: 280px 1fr; gap: 1.2rem; align-items: start; }
.profile-info-box table td { padding: .3rem .4rem; border: none; }
@media (max-width: 700px) { .profile-layout { grid-template-columns: 1fr; } }

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .header-inner { flex-direction: column; height: auto; padding: .6rem 0; gap: .4rem; }
    .header-instructions { position: static; transform: none; font-size: .85rem; }
    .auth-box { padding: 1.5rem; }
    .dashboard-cards { flex-direction: column; }
    .form-grid { grid-template-columns: 1fr; }
}
