/* ==========================================================================
   KPI CST Admin — Design Tokens
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Color */
    --primary-color: #0B4D3C;      /* deep institutional green   */
    --primary-dark: #073328;
    --primary-light: #E7F1EC;
    --secondary-color: #C9A227;    /* muted gold, accent only    */
    --secondary-light: #FBF3DD;
    --bg-light: #F5F7F6;
    --surface: #FFFFFF;
    --border: #E3E8E6;
    --text-dark: #16241E;
    --text-muted: #647069;
    --danger: #C0392B;
    --danger-light: #FBEAE8;
    --info: #2F6F8F;
    --info-light: #E9F2F6;

    /* Type */
    --font-display: 'Sora', 'Segoe UI', sans-serif;
    --font-body: 'Inter', 'Segoe UI', sans-serif;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(11, 77, 60, 0.06);
    --shadow-md: 0 6px 16px rgba(11, 77, 60, 0.08);
    --shadow-lg: 0 16px 40px rgba(11, 77, 60, 0.14);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
    display: flex;
    background-color: var(--bg-light);
    font-family: var(--font-body);
    color: var(--text-dark);
    line-height: 1.5;
}

::selection { background: var(--secondary-light); color: var(--primary-dark); }

/* Visible focus for accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
    width: 260px;
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #EFF6F3;
    padding: 24px 16px;
    position: fixed;
    display: flex;
    flex-direction: column;
    border-right: 3px solid var(--secondary-color);
}

.sidebar .logo {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 0.2px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar .logo i {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(201, 162, 39, 0.18);
    color: var(--secondary-color);
    border-radius: var(--radius-sm);
    font-size: 17px;
}

.sidebar nav {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(239, 246, 243, 0.78);
    text-decoration: none;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.sidebar nav a i {
    width: 18px;
    text-align: center;
    font-size: 15px;
}

.sidebar nav a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #FFFFFF;
}

.sidebar nav a.active {
    background: rgba(201, 162, 39, 0.14);
    color: #FFFFFF;
    border-left: 3px solid var(--secondary-color);
    font-weight: 600;
}

/* ==========================================================================
   Main layout
   ========================================================================== */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 32px 40px 60px;
    min-width: 0;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-dark);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    padding: 8px 16px 8px 18px;
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.user-info span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.user-info i {
    font-size: 28px;
    color: var(--primary-color);
}

.content-section { display: none; }
.content-section.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Dashboard stat cards
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.stat-card {
    background: var(--surface);
    padding: 22px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-top: 3px solid var(--primary-color);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card i {
    font-size: 26px;
    color: var(--primary-color);
    background: var(--primary-light);
    width: 56px;
    height: 56px;
    min-width: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.stat-card h3 {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    color: var(--text-dark);
}

.stat-card p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ==========================================================================
   Cards / forms
   ========================================================================== */
.action-card, .notice-list {
    background: var(--surface);
    padding: 28px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.notice-list { margin-top: 24px; }

.action-card h2, .notice-list h2 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-dark);
    position: relative;
    padding-left: 14px;
}

.action-card h2::before, .notice-list h2::before {
    content: "";
    position: absolute;
    left: 0;
    top: 2px;
    bottom: 2px;
    width: 4px;
    border-radius: 2px;
    background: var(--secondary-color);
}

form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 22px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

input, select, textarea {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-dark);
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder, textarea::placeholder { color: #9AA6A0; }

input:hover, select:hover, textarea:hover { border-color: #C9D3CE; }

input:focus, select:focus, textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input[type="file"] {
    padding: 9px 14px;
    background: var(--bg-light);
    cursor: pointer;
}

textarea { resize: vertical; min-height: 90px; }

.btn-submit {
    background: var(--primary-color);
    color: #ffffff;
    padding: 13px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 14.5px;
    letter-spacing: 0.2px;
    transition: background 0.18s ease, transform 0.05s ease;
}

.btn-submit:hover { background: var(--primary-dark); }
.btn-submit:active { transform: scale(0.99); }

/* ==========================================================================
   Tables
   ========================================================================== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 14px;
}

th, td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-light);
    color: var(--primary-dark);
    font-family: var(--font-display);
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: var(--primary-light); }

td img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--border);
}

.btn-delete, .btn-edit {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 15px;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.btn-edit { color: var(--info); }
.btn-edit:hover { background: var(--info-light); }

.btn-delete { color: var(--danger); margin-left: 6px; }
.btn-delete:hover { background: var(--danger-light); }

/* ==========================================================================
   Gallery
   ========================================================================== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.gallery-item {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    height: 130px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
}

.gallery-item:hover img { transform: scale(1.06); }

.gallery-item .btn-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Filter tabs, search rows, count badges
   ========================================================================== */
.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 9px 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13.5px;
    transition: all 0.18s ease;
}

.tab-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }

.tab-btn.active {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

.semester-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.semester-filter-row select, .search-box {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    outline: none;
    font-size: 14px;
    font-family: var(--font-body);
}

.search-box {
    flex-grow: 1;
    min-width: 220px;
    background: var(--bg-light) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23647069' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E") no-repeat 14px center;
    padding-left: 38px;
}

.count-badge {
    background: var(--secondary-light);
    color: #8A6C10;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 51, 40, 0.55);
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--surface);
    margin: 4% auto;
    padding: 28px;
    border-radius: var(--radius-lg);
    width: 50%;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border-top: 4px solid var(--secondary-color);
    animation: fadeIn 0.2s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--primary-dark);
}

.close {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.close:hover { background: var(--danger-light); color: var(--danger); }

/* ==========================================================================
   Image previews
   ========================================================================== */
.preview-img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-top: 10px;
    display: none;
    border: 2px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.form-row div { flex: 1; display: flex; flex-direction: column; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .modal-content { width: 70%; }
}

@media (max-width: 768px) {
    .sidebar {
        width: 72px;
        padding: 20px 8px;
    }
    .sidebar .logo span,
    .sidebar nav a span,
    .sidebar nav a { justify-content: center; }
    .sidebar .logo span { display: none; }
    .sidebar nav a { justify-content: center; padding: 12px; }
    .sidebar nav a span { display: none; }
    .main-content { margin-left: 72px; padding: 24px 18px 48px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .modal-content { width: 92%; margin: 8% auto; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    header { flex-direction: column; align-items: flex-start; gap: 14px; }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}