:root {
    /* BMA Colors */
    --primary: #00744B;
    --primary-dark: #004D33;
    --primary-light: #E8F5E9;
    --accent: #D4A843;
    --danger: #E53935;
    --success: #2E7D32;
    --warning: #F57F17;
    
    /* Grayscale */
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;
    
    --bg-main: var(--gray-50);
    --card-bg: #FFFFFF;
    
    --font-family: 'Noto Sans Thai', 'Inter', sans-serif;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --border-radius: 0.5rem;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--gray-800);
    line-height: 1.5;
}

/* Utilities */
.d-none { display: none !important; }
.text-center { text-align: center; }
.mt-2 { margin-top: 0.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-5 { padding-top: 2rem; padding-bottom: 2rem; }
.text-sm { font-size: 0.875rem; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--gray-500); }
.text-warning { color: var(--warning); }
.justify-center { justify-content: center; }
.flex-grow { flex: 1; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 116, 75, 0.2);
}
.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-success {
    background-color: #2E7D32;
    color: white;
    box-shadow: 0 2px 4px rgba(46, 125, 50, 0.2);
}
.btn-success:hover {
    background-color: #1B5E20;
}

.btn-warning {
    background-color: #F57F17;
    color: white;
}
.btn-warning:hover {
    background-color: #E65100;
}

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

.btn-outline {
    background-color: transparent;
    border-color: var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover {
    background-color: var(--gray-100);
}

.btn-outline-primary {
    background-color: #E8F5E9;
    border-color: #A5D6A7;
    color: var(--primary-dark);
}
.btn-outline-primary:hover {
    background-color: var(--primary);
    color: white;
}

.btn-outline-success {
    background-color: #E8F5E9;
    border-color: #81C784;
    color: #2E7D32;
}
.btn-outline-success:hover {
    background-color: #2E7D32;
    color: white;
}

.btn-outline-warning {
    background-color: #FFF8E1;
    border-color: #FFE082;
    color: #F57F17;
}
.btn-outline-warning:hover {
    background-color: #F57F17;
    color: white;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Requirement 9: Prominent Download Button for ZIP */
.btn-zip-download {
    font-weight: 700;
    border-width: 1.5px;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-700);
}

.filter-label {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
    display: block;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
select {
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: 0.875rem;
    transition: border-color 0.2s;
    background-color: white;
}

select.select-lg {
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-dark);
    border: 2px solid #A5D6A7;
    background-color: #F4FBF7;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 116, 75, 0.15);
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -5px;
    margin-left: -5px;
}
.col-md-3 { width: 25%; padding: 0 5px; }
.col-md-4 { width: 33.33%; padding: 0 5px; }
.col-md-5 { width: 41.66%; padding: 0 5px; }
.col-md-6 { width: 50%; padding: 0 5px; }
.col-md-12 { width: 100%; padding: 0 5px; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Login Screen */
.login-wrapper {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    padding: 1rem;
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 1.25rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}
.login-header h2 {
    color: var(--primary-dark);
    font-size: 1.35rem;
    font-weight: 700;
}
.login-header p {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-top: 0.2rem;
}

.alert {
    padding: 0.75rem;
    border-radius: var(--border-radius);
    margin-top: 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.alert-error {
    background-color: #FEE2E2;
    color: #991B1B;
}

/* Main Layout */
.app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.sidebar-logo {
    height: 44px;
    width: 44px;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid var(--gray-200);
}

.sidebar-header h3 {
    color: var(--primary-dark);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.sidebar-header p {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.5rem;
    color: var(--gray-600);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-item:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.nav-item.active {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    border-right: 4px solid var(--primary);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--gray-200);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.top-header {
    background: linear-gradient(to right, var(--primary-dark), var(--primary));
    color: white;
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.header-title h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.875rem;
}

.avatar {
    width: 34px;
    height: 34px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.content-body {
    padding: 1.75rem;
    flex: 1;
}

/* Cards & Components */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.filters-card {
    display: flex;
    gap: 1.25rem;
    align-items: flex-end;
    padding: 1.25rem 1.5rem;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    min-width: 240px;
}
.search-box i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}
.search-box input {
    padding-left: 2.35rem;
}

/* Requirement 6: Placeholder Select State */
.placeholder-select-state {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 2px dashed var(--gray-200);
}

.placeholder-select-state h3 {
    margin-top: 1rem;
    color: var(--gray-700);
    font-size: 1.15rem;
}

/* Officer Training Cards */
.officer-cards-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.officer-training-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.officer-header {
    padding: 1.1rem 1.5rem;
    background: var(--gray-50);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-200);
}
.officer-header:hover {
    background: var(--primary-light);
}

.pos-number-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(0, 116, 75, 0.1);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.25rem;
}

.officer-info h4 {
    color: var(--gray-800);
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
}
.officer-info p {
    color: var(--gray-500);
    font-size: 0.85rem;
}

.officer-actions-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.progress-badge {
    background: var(--gray-200);
    color: var(--gray-700);
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.825rem;
    font-weight: 700;
}
.progress-badge.complete {
    background: #DCFCE7;
    color: #15803D;
}

.courses-list {
    padding: 1.25rem 1.5rem;
    display: none;
    background: #FAFAFA;
}
.courses-list.active {
    display: block;
}

.course-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-200);
    margin-bottom: 0.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.course-item.is-completed {
    border-left: 4px solid var(--primary);
    background: #F4FBF7;
}

.course-info h5 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    color: var(--gray-800);
}

.course-code-tag {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.course-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-wrap: wrap;
}

.status-pass-badge {
    font-size: 0.825rem;
    font-weight: 600;
    color: #15803D;
    background: #DCFCE7;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
}

.status-incomplete-badge {
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
}

.pending-upload-badge {
    font-size: 0.8rem;
    font-weight: 600;
    color: #854D0E;
    background: #FEF9C3;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    border: 1px solid #FEF08A;
}

/* Requirement 7: Slide Switch Styling */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
    flex-shrink: 0;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #CBD5E1;
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.upload-btn-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
}
.upload-btn-wrapper input[type=file] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
}

/* Table */
.table-responsive {
    overflow-x: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}
.data-table th {
    background-color: var(--gray-50);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--gray-700);
}
.data-table tbody tr:hover {
    background-color: var(--gray-50);
}

.action-btn-group {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.775rem;
    font-weight: 600;
}
.badge-success { background: #DCFCE7; color: #166534; }
.badge-warning { background: #FEF9C3; color: #854D0E; }
.badge-active { background: #E0F2FE; color: #0369A1; }
.badge-inactive { background: #FEE2E2; color: #991B1B; }

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal.active {
    display: flex;
}

.modal-content {
    background-color: white;
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 650px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.modal-sm { max-width: 420px; }

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--gray-50);
}
.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-dark);
}
.close-modal {
    background: none;
    border: none;
    font-size: 1.75rem;
    cursor: pointer;
    color: var(--gray-400);
    line-height: 1;
}
.close-modal:hover {
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    background-color: var(--gray-50);
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: white;
    padding: 0.85rem 1.25rem;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

.toast.success { border-left: 5px solid var(--success); }
.toast.error { border-left: 5px solid var(--danger); }
.toast.info { border-left: 5px solid #0284C7; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 768px) {
    .app-wrapper {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    .sidebar {
        width: 100%;
        height: auto;
    }
    .sidebar-nav {
        display: flex;
        padding: 0.5rem;
        overflow-x: auto;
    }
    .nav-item {
        padding: 0.5rem 1rem;
        white-space: nowrap;
    }
    .nav-item.active {
        border-right: none;
        border-bottom: 3px solid var(--primary);
    }
    .filters-card {
        flex-direction: column;
        align-items: stretch;
    }
    .search-box {
        min-width: 100%;
    }
    .col-md-3, .col-md-4, .col-md-5, .col-md-6 {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}
