@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #0A4D34;
    --primary-light: #156E4C;
    --primary-dark: #063423;
    --accent-color: #D4AF37;
    --accent-light: #E6C555;
    --accent-dark: #AA841B;
    --bg-light: #F4F7F5;
    --surface-light: #FFFFFF;
    --text-light: #1C2D27;
    --text-muted-light: #60796F;
    --border-light: rgba(10, 77, 52, 0.1);
    
    --bg-dark: #081712;
    --surface-dark: #0F251E;
    --text-dark: #E2ECE8;
    --text-muted-dark: #8BA89C;
    --border-dark: rgba(212, 175, 55, 0.15);
    
    --success: #2E7D32;
    --warning: #EF6C00;
    --danger: #C62828;
    --info: #0288D1;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 16px 32px rgba(10, 77, 52, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Mode Defaults */
body {
    background-color: var(--bg-light);
    color: var(--text-light);
    font-family: 'Sarabun', 'Outfit', sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    transition: var(--transition);
}

/* Dark Mode Classes */
body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-dark);
}

* {
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-light) transparent;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Sidebar Layout */
.sidebar {
    width: 280px;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    border-right: 2px solid var(--accent-color);
    transition: var(--transition);
}

.sidebar-header {
    padding: 30px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.sidebar-logo {
    width: 70px;
    height: 70px;
    margin-bottom: 15px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
    object-fit: contain;
}

.sidebar-title {
    font-size: 1.02rem;
    font-weight: 700;
    margin: 0;
    color: #FFFFFF;
    letter-spacing: 0.5px;
    line-height: 1.3;
    word-break: keep-all;
}

.sidebar-subtitle {
    font-size: 0.75rem;
    color: var(--accent-color);
    margin: 5px 0 0 0;
    font-weight: 500;
    letter-spacing: 1px;
}

.menu-items {
    list-style: none;
    padding: 20px 12px;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.menu-item {
    margin-bottom: 6px;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.menu-link i {
    width: 24px;
    font-size: 1.15rem;
    margin-right: 12px;
    transition: var(--transition);
}

.menu-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--accent-color);
}

.menu-item.active .menu-link {
    background: rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
    border-left-color: var(--accent-color);
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.05);
}

.menu-item.active .menu-link i {
    color: var(--accent-color);
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 0.85rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #FFF;
}

.user-role {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
}

.theme-toggle-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 6px;
    border-radius: 50%;
    transition: var(--transition);
}

.theme-toggle-btn:hover {
    color: var(--accent-color);
    background: rgba(255, 255, 255, 0.05);
}

/* Main Content Area */
.main-wrapper {
    margin-left: 280px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

.header {
    height: 80px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--surface-light);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

body.dark-mode .header {
    background: var(--surface-dark);
    border-bottom: 1px solid var(--border-dark);
}

.header-title-section {
    display: flex;
    flex-direction: column;
}

.header-page-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
}

.header-academic-year-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-academic-year-selector label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted-light);
}

body.dark-mode .header-academic-year-selector label {
    color: var(--text-muted-dark);
}

.form-select {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    background-color: var(--surface-light);
    color: var(--text-light);
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

body.dark-mode .form-select {
    border: 1px solid var(--border-dark);
    background-color: var(--surface-dark);
    color: var(--text-dark);
}

.form-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.content-container {
    padding: 40px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Page sections (shown/hidden dynamically) */
.page-section {
    display: none;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.page-section.active {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Grid System for Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.dashboard-kpi-row {
    grid-column: span 3;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.kpi-card {
    background: var(--surface-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

body.dark-mode .kpi-card {
    background: var(--surface-dark);
    border-color: var(--border-dark);
}

.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-color);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
}

.kpi-card.kpi-gold::before {
    background: var(--accent-color);
}

.kpi-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kpi-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

body.dark-mode .kpi-title {
    color: var(--text-muted-dark);
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.1;
    font-family: 'Outfit', sans-serif;
    color: var(--primary-color);
}

.kpi-card.kpi-gold .kpi-value {
    color: var(--accent-dark);
}

body.dark-mode .kpi-card.kpi-gold .kpi-value {
    color: var(--accent-color);
}

body.dark-mode .kpi-value {
    color: var(--text-dark);
}

.kpi-unit {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted-light);
    margin-left: 5px;
}

body.dark-mode .kpi-unit {
    color: var(--text-muted-dark);
}

.kpi-icon-container {
    width: 60px;
    height: 60px;
    background: rgba(10, 77, 52, 0.05);
    color: var(--primary-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.kpi-card.kpi-gold .kpi-icon-container {
    background: rgba(212, 175, 55, 0.1);
    color: var(--accent-dark);
}

body.dark-mode .kpi-icon-container {
    background: rgba(255, 255, 255, 0.03);
    color: var(--accent-color);
}

/* Chart Card & Recent Card */
.dashboard-chart-card {
    grid-column: span 1;
    background: var(--surface-light);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dashboard-recent-card {
    grid-column: span 2;
    background: var(--surface-light);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

body.dark-mode .dashboard-chart-card,
body.dark-mode .dashboard-recent-card {
    background: var(--surface-dark);
    border-color: var(--border-dark);
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 18px;
    background: var(--accent-color);
    border-radius: 3px;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Beautiful Modern Table styling */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

body.dark-mode .table-responsive {
    border-color: var(--border-dark);
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.custom-table th {
    background-color: rgba(10, 77, 52, 0.04);
    color: var(--primary-color);
    font-weight: 600;
    padding: 16px 20px;
    border-bottom: 2px solid var(--border-light);
    white-space: nowrap;
}

body.dark-mode .custom-table th {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-dark);
    border-bottom: 2px solid var(--border-dark);
}

.custom-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-light);
    vertical-align: middle;
}

body.dark-mode .custom-table td {
    border-bottom: 1px solid var(--border-dark);
    color: var(--text-dark);
}

.custom-table tr:last-child td {
    border-bottom: none;
}

.custom-table tr:hover td {
    background-color: rgba(10, 77, 52, 0.015);
}

body.dark-mode .custom-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.01);
}

/* Table Badge Styling */
.badge {
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
    text-align: center;
}

.badge-primary {
    background-color: rgba(10, 77, 52, 0.1);
    color: var(--primary-color);
}

body.dark-mode .badge-primary {
    background-color: rgba(226, 236, 232, 0.08);
    color: var(--text-dark);
}

.badge-success {
    background-color: rgba(46, 125, 50, 0.1);
    color: var(--success);
}

.badge-warning {
    background-color: rgba(239, 108, 0, 0.1);
    color: var(--warning);
}

.badge-gold {
    background-color: rgba(212, 175, 55, 0.15);
    color: var(--accent-dark);
}

body.dark-mode .badge-gold {
    color: var(--accent-light);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(10, 77, 52, 0.2);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-light);
}

body.dark-mode .btn-secondary {
    border: 1px solid var(--border-dark);
    color: var(--text-dark);
}

.btn-secondary:hover {
    background-color: rgba(10, 77, 52, 0.04);
}

body.dark-mode .btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.btn-accent {
    background-color: var(--accent-color);
    color: var(--primary-dark);
}

.btn-accent:hover {
    background-color: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.btn-danger {
    background-color: rgba(198, 40, 40, 0.1);
    color: var(--danger);
}

.btn-danger:hover {
    background-color: var(--danger);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 4px;
}

/* Tool Actions & Filters Row */
.filter-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    background: var(--surface-light);
    padding: 20px 30px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

body.dark-mode .filter-row {
    background: var(--surface-dark);
    border-color: var(--border-dark);
}

.search-input-group {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-input-group i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted-light);
}

body.dark-mode .search-input-group i {
    color: var(--text-muted-dark);
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 44px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background-color: var(--bg-light);
    color: var(--text-light);
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

body.dark-mode .search-input {
    border-color: var(--border-dark);
    background-color: var(--bg-dark);
    color: var(--text-dark);
}

.search-input:focus {
    border-color: var(--accent-color);
    background-color: var(--surface-light);
}

body.dark-mode .search-input:focus {
    background-color: var(--surface-dark);
}

.filter-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.col-span-2 {
    grid-column: span 2;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted-light);
}

body.dark-mode .form-group label {
    color: var(--text-muted-dark);
}

.form-control {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background-color: var(--bg-light);
    color: var(--text-light);
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

body.dark-mode .form-control {
    border-color: var(--border-dark);
    background-color: var(--bg-dark);
    color: var(--text-dark);
}

.form-control:focus {
    border-color: var(--accent-color);
    background-color: var(--surface-light);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

body.dark-mode .form-control:focus {
    background-color: var(--surface-dark);
}

/* Modal styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-container {
    background: var(--surface-light);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--accent-color);
    animation: modalScaleUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: var(--transition);
}

body.dark-mode .modal-container {
    background: var(--surface-dark);
}

.modal-container.wide {
    max-width: 900px;
}

@keyframes modalScaleUp {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 24px 30px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body.dark-mode .modal-header {
    border-bottom-color: var(--border-dark);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

body.dark-mode .modal-title {
    color: var(--accent-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted-light);
    transition: var(--transition);
}

body.dark-mode .modal-close {
    color: var(--text-muted-dark);
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

body.dark-mode .modal-footer {
    border-top-color: var(--border-dark);
}

/* Recipient Entry Row for Form */
.recipient-entry-box {
    border: 1px dashed var(--border-light);
    padding: 16px;
    border-radius: var(--radius-sm);
    background: rgba(10, 77, 52, 0.02);
    margin-bottom: 12px;
    position: relative;
}

body.dark-mode .recipient-entry-box {
    border: 1px dashed var(--border-dark);
    background: rgba(255, 255, 255, 0.01);
}

.btn-remove-recipient {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
}

/* Lock Screen Overlay for Document Tab */
.lock-container {
    max-width: 400px;
    margin: 60px auto;
    background: var(--surface-light);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}

body.dark-mode .lock-container {
    background: var(--surface-dark);
    border-color: var(--border-dark);
}

.lock-icon {
    width: 80px;
    height: 80px;
    background: rgba(212, 175, 55, 0.1);
    color: var(--accent-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    margin-bottom: 10px;
}

body.dark-mode .lock-icon {
    color: var(--accent-light);
}

.lock-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
}

.lock-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted-light);
    margin: 0;
}

body.dark-mode .lock-subtitle {
    color: var(--text-muted-dark);
}

/* Timeline component for History */
.timeline {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 0;
}

.timeline::before {
    content: '';
    position: absolute;
    width: 2px;
    background: var(--border-light);
    top: 0;
    bottom: 0;
    left: 40px;
}

body.dark-mode .timeline::before {
    background: var(--border-dark);
}

.timeline-item {
    position: relative;
    margin-bottom: 30px;
    padding-left: 80px;
}

.timeline-marker {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    border: 4px solid var(--surface-light);
    left: 31px;
    top: 5px;
    box-shadow: 0 0 0 3px rgba(10, 77, 52, 0.1);
    z-index: 2;
}

body.dark-mode .timeline-marker {
    border-color: var(--surface-dark);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.timeline-content {
    background: var(--surface-light);
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

body.dark-mode .timeline-content {
    background: var(--surface-dark);
    border-color: var(--border-dark);
}

.timeline-year {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-dark);
    text-transform: uppercase;
    margin-bottom: 5px;
}

body.dark-mode .timeline-year {
    color: var(--accent-light);
}

.timeline-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 10px 0;
}

.timeline-details {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 0.85rem;
}

/* Individual Search Results Area */
.profile-summary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: var(--radius-lg);
    padding: 30px;
    display: flex;
    align-items: center;
    gap: 30px;
    border: 1px solid var(--accent-color);
}

.profile-avatar {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
}

.profile-info {
    flex: 1;
}

.profile-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.profile-meta {
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
    margin-top: 10px;
    color: rgba(255, 255, 255, 0.8);
}

.profile-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.profile-meta i {
    color: var(--accent-color);
}

/* Document Grid */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.doc-card {
    background: var(--surface-light);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 15px;
    transition: var(--transition);
}

body.dark-mode .doc-card {
    background: var(--surface-dark);
    border-color: var(--border-dark);
}

.doc-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-color);
}

.doc-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.doc-icon {
    font-size: 2rem;
    color: var(--primary-color);
}

body.dark-mode .doc-icon {
    color: var(--accent-color);
}

.doc-details {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.doc-name {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
}

.doc-meta {
    font-size: 0.75rem;
    color: var(--text-muted-light);
    margin-top: 4px;
}

body.dark-mode .doc-meta {
    color: var(--text-muted-dark);
}

.doc-action {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: auto;
}

/* Annual Report print view wrapper */
.report-paper {
    background: var(--surface-light);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 30px;
    transition: var(--transition);
}

body.dark-mode .report-paper {
    background: var(--surface-dark);
    border-color: var(--border-dark);
}

.report-header {
    text-align: center;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.report-logo {
    width: 60px;
    height: 60px;
}

.report-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    color: var(--primary-color);
}

body.dark-mode .report-title {
    color: var(--accent-color);
}

.report-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted-light);
    margin: 0;
}

body.dark-mode .report-subtitle {
    color: var(--text-muted-dark);
}

.report-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}

/* Inline Google Drive link for documents registry */
.drive-link-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #34A853;
    font-weight: 600;
    background: rgba(52, 168, 83, 0.08);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.82rem;
    text-decoration: none;
    transition: var(--transition);
    margin-left: 8px;
    vertical-align: middle;
}

.drive-link-inline:hover {
    background: rgba(52, 168, 83, 0.16);
    transform: translateY(-1px);
}

body.dark-mode .drive-link-inline {
    color: #4cd964;
    background: rgba(76, 217, 100, 0.1);
}

body.dark-mode .drive-link-inline:hover {
    background: rgba(76, 217, 100, 0.2);
}

/* App Bottom Sticky/Flex Footer Bar */
.app-footer {
    width: 100%;
    background: var(--surface-light);
    border-top: 1px solid var(--border-light);
    padding: 15px 40px;
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-muted-light);
    font-weight: 600;
    transition: var(--transition);
    margin-top: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.02);
}

body.dark-mode .app-footer {
    background: var(--surface-dark);
    border-top-color: var(--border-dark);
    color: var(--text-muted-dark);
}

/* Print-only elements defaults */
.print-only-header {
    display: none;
}

/* Print Styles */
@media print {
    /* Define A4 page margins */
    @page {
        size: A4 portrait;
        margin: 15mm 15mm 15mm 15mm;
    }

    /* Force background colors and charts to print correctly */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body, html {
        background: white !important;
        color: black !important;
        font-family: "TH Sarabun New", "TH Sarabun PSK", "TH Sarabun", "Sarabun", sans-serif !important;
        font-size: 16pt !important;
        width: 100% !important;
        height: auto !important;
        line-height: 1.25 !important;
    }
    
    .sidebar, .header, .filter-row, .btn, .theme-toggle-btn, #db-utility-bar, .modal-overlay, .admin-controls, .form-container, .modal, .app-footer {
        display: none !important;
    }

    .drive-link-inline {
        color: black !important;
        background: transparent !important;
        border: 1px solid #999 !important;
        padding: 1px 4px !important;
        font-size: 12pt !important;
        margin-left: 8px !important;
        text-decoration: none !important;
    }
    .drive-link-inline i {
        color: black !important;
    }
    
    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .content-container {
        padding: 0 !important;
    }
    
    .page-section {
        display: none !important;
    }
    
    .page-section.active {
        display: block !important;
        width: 100% !important;
    }
    
    /* Show print headers */
    .print-only-header {
        display: block !important;
        margin-bottom: 15px !important;
    }

    .print-only-header h3 {
        font-size: 18pt !important;
        font-weight: bold !important;
        margin-bottom: 5px !important;
    }

    .print-only-header p {
        font-size: 16pt !important;
    }
    
    /* Reset cards and containers for clean printing */
    .kpi-card, .dashboard-chart-card, .dashboard-recent-card, .table-responsive {
        background: white !important;
        border: 1px solid #bbb !important;
        box-shadow: none !important;
        transform: none !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }
    
    /* The report paper should look like a clean document page without box borders */
    .report-paper {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .report-title {
        font-size: 20pt !important;
        font-weight: bold !important;
        color: black !important;
    }

    .report-subtitle {
        font-size: 16pt !important;
        color: black !important;
    }

    .kpi-title {
        font-size: 16pt !important;
        color: black !important;
    }

    .kpi-value {
        font-size: 20pt !important;
        font-weight: bold !important;
        color: black !important;
    }

    .kpi-unit {
        font-size: 16pt !important;
        color: black !important;
    }

    .card-title {
        font-size: 18pt !important;
        font-weight: bold !important;
        color: black !important;
    }

    .kpi-icon-container {
        display: none !important; /* Hide icons in KPI cards when printing to save ink and look cleaner */
    }
    
    /* Table styles optimized for printing to fit perfectly and not look bulky */
    .table-responsive {
        overflow: visible !important; /* No scrollbars on paper */
        border: none !important;
    }

    .custom-table {
        border-collapse: collapse !important;
        width: 100% !important;
        max-width: 100% !important;
        table-layout: auto !important;
        page-break-inside: auto;
    }

    .custom-table tr {
        page-break-inside: avoid !important;
        page-break-after: auto !important;
    }
    
    .custom-table th {
        background-color: #f5f5f5 !important;
        color: black !important;
        border: 1px solid #999 !important;
        border-bottom: 2px solid black !important;
        padding: 5px 8px !important; /* Compact padding for non-bulky tables */
        font-size: 16pt !important;
        font-weight: bold !important;
        text-align: center !important;
    }
    
    .custom-table td {
        background-color: white !important;
        color: black !important;
        border: 1px solid #ccc !important;
        padding: 5px 8px !important; /* Compact padding for non-bulky tables */
        font-size: 16pt !important;
        word-wrap: break-word !important;
        white-space: normal !important;
    }

    .custom-table tfoot td {
        font-size: 16pt !important;
        font-weight: bold !important;
        padding: 5px 8px !important;
        border-top: 2px solid black !important;
    }
    
    /* Hide actions and details columns */
    #dashboard-recent-table th:last-child, #dashboard-recent-table td:last-child,
    #special-scholarships-table th:last-child, #special-scholarships-table td:last-child,
    #incoming-scholarships-table th:last-child, #incoming-scholarships-table td:last-child,
    #recipients-table th:last-child, #recipients-table td:last-child,
    #documents-table th:last-child, #documents-table td:last-child {
        display: none !important;
    }

    /* Print-specific layout for dashboard to prevent overflow/clipping */
    .dashboard-grid {
        display: block !important;
        width: 100% !important;
    }
    .dashboard-kpi-row {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
        margin-bottom: 15px !important;
        width: 100% !important;
    }
    .kpi-card {
        padding: 10px 12px !important;
    }
    .dashboard-chart-card, .dashboard-recent-card {
        margin-bottom: 15px !important;
        width: 100% !important;
        padding: 15px 15px !important;
    }
    .chart-wrapper {
        height: 180px !important; /* reduce height on paper to keep page compact */
    }
    
    /* Badges in tables during printing: clean up colors/borders */
    .badge {
        border: 1px solid #999 !important;
        background-color: #f9f9f9 !important;
        color: black !important;
        padding: 2px 6px !important;
        font-size: 14pt !important;
    }
}