/* ===================================================================
   Procurement System — Design System
   Premium institutional UI with navy/gold color scheme
   =================================================================== */

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

/* ===== DESIGN TOKENS ===== */
:root {
    --primary: #1a365d;
    --primary-light: #2c5282;
    --primary-dark: #0f2440;
    --primary-50: #ebf4ff;
    --primary-100: #c3dafe;
    --accent: #c69214;
    --accent-light: #d4a843;
    --accent-dark: #a07810;
    --accent-50: #fef9e7;
    --bg: #f0f2f7;
    --surface: #ffffff;
    --surface-alt: #f7fafc;
    --text: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --border: #e2e8f0;
    --border-light: #edf2f7;
    --success: #38a169;
    --success-bg: #f0fff4;
    --danger: #e53e3e;
    --danger-bg: #fff5f5;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
    --shadow-xl: 0 25px 50px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --topbar-h: 64px;
}

/* ===== BASE ===== */
html { scroll-behavior: smooth; }
body {
    font-family: 'Kanit', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===== ACCENT LINE ===== */
.accent-line {
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light), var(--accent));
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
}

/* ===== TOPBAR ===== */
.topbar {
    position: fixed;
    top: 4px;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.topbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar-left { display: flex; align-items: center; }
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #fff;
}
.brand-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--accent-light);
    backdrop-filter: blur(4px);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }
.brand-subtitle { font-weight: 300; font-size: 0.65rem; opacity: 0.6; letter-spacing: 0.05em; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.topbar-link {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition);
}
.topbar-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}
.topbar-login {
    background: rgba(198,146,20,0.2);
    color: var(--accent-light);
    border: 1px solid rgba(198,146,20,0.3);
}
.topbar-login:hover {
    background: var(--accent);
    color: #fff;
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: rgba(255,255,255,0.08);
    border-radius: var(--radius-full);
    border: 1px solid rgba(255,255,255,0.1);
}
.user-avatar {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.75rem;
}
.user-name { color: rgba(255,255,255,0.9); font-size: 0.8rem; font-weight: 400; }
.admin-badge {
    background: var(--accent);
    color: var(--primary-dark);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    letter-spacing: 0.03em;
}
.topbar-toggle {
    display: none;
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* ===== MAIN CONTAINER ===== */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: calc(var(--topbar-h) + 4px + 2rem) 1.5rem 3rem;
}

/* ===== PAGE HEADER ===== */
.page-header {
    margin-bottom: 2rem;
}
.page-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.page-header h1 i { color: var(--accent); font-size: 1.4rem; }
.page-header p { color: var(--text-secondary); font-size: 0.9rem; font-weight: 300; }

/* ===== TABS ===== */
.tabs-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border-light);
}
.tabs-header {
    display: flex;
    border-bottom: 2px solid var(--border-light);
    background: var(--surface-alt);
    position: relative;
    overflow-x: auto;
}
.tab-btn {
    flex: 1;
    min-width: 180px;
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}
.tab-btn i { font-size: 0.9rem; }
.tab-btn:hover { color: var(--primary); background: rgba(26,54,93,0.04); }
.tab-btn.active {
    color: var(--primary);
    font-weight: 600;
    background: var(--surface);
}
.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 1rem;
    right: 1rem;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 3px 3px 0 0;
}

/* ===== TAB TOOLBAR ===== */
.tab-toolbar {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 1rem;
}
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    justify-content: flex-end;
}

.search-box {
    position: relative;
    max-width: 320px;
    width: 100%;
}

.search-box .search-icon {
    position: absolute;
    left: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
    transition: var(--transition);
}

.search-box input {
    width: 100%;
    padding: 0.65rem 1rem 0.65rem 2.8rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: var(--surface);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 4px 12px rgba(198,146,20,0.12), 0 0 0 4px rgba(198,146,20,0.05);
    width: 100%;
}

.search-box input:focus + .search-icon {
    color: var(--accent);
}

.search-box input::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

/* ===== PAGINATION ===== */
.limit-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.limit-selector select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font-family: inherit;
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
}

.pagination-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--surface-alt);
    border-top: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    gap: 0.25rem;
}

.page-btn {
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
    background: var(--primary-50);
    border-color: var(--primary-100);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(26, 54, 93, 0.2);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.tab-toolbar .tab-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}
.tab-toolbar .tab-info strong { color: var(--text-secondary); font-weight: 600; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 2px 8px rgba(26,54,93,0.25);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(26,54,93,0.35);
}
.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    box-shadow: 0 2px 8px rgba(198,146,20,0.25);
}
.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(198,146,20,0.35);
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-alt); border-color: var(--text-muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c53030; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.75rem; border-radius: 8px; }
.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.8rem;
}
.btn-icon-edit { background: var(--primary-50); color: var(--primary-light); border: 1px solid var(--primary-100); }
.btn-icon-edit:hover { background: var(--primary); color: #fff; }
.btn-icon-delete { background: var(--danger-bg); color: var(--danger); border: 1px solid #fed7d7; }
.btn-icon-delete:hover { background: var(--danger); color: #fff; }

/* ===== TABLE ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table thead th {
    padding: 0.85rem 1.5rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
}
.data-table thead th:last-child { text-align: center; }
.data-table tbody tr {
    transition: var(--transition);
    border-bottom: 1px solid var(--border-light);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(26,54,93,0.02); }
.data-table tbody td {
    padding: 1rem 1.5rem;
    font-size: 0.85rem;
    vertical-align: middle;
}
.data-table .col-title {
    font-weight: 500;
    color: var(--text);
    max-width: 400px;
}
.data-table .col-year {
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
    text-align: center;
}
.data-table .col-files {
    white-space: nowrap;
}
.data-table .col-actions {
    text-align: center;
    white-space: nowrap;
}
.data-table .col-actions .action-group {
    display: flex;
    gap: 0.35rem;
    justify-content: center;
}
.data-table .row-num {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
    width: 50px;
}

/* ===== FILE BADGES ===== */
.file-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    margin-right: 0.35rem;
}
.file-badge:last-child { margin-right: 0; }
.file-badge-xlsx {
    background: #f0fff4;
    color: #276749;
    border: 1px solid #c6f6d5;
}
.file-badge-xlsx:hover {
    background: #276749;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(39,103,73,0.2);
}
.file-badge-pdf {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #fed7d7;
}
.file-badge-pdf:hover {
    background: #c53030;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(197,48,48,0.2);
}
.file-badge i { font-size: 0.8rem; }
.no-file { color: var(--text-muted); font-size: 0.8rem; font-style: italic; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.3; }
.empty-state p { font-size: 0.9rem; font-weight: 400; }

/* ===== LOADING ===== */
.loading-state {
    text-align: center;
    padding: 3rem;
    color: var(--primary);
}
.loading-state i { font-size: 2rem; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15,36,64,0.6);
    backdrop-filter: blur(6px);
}
.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.active .modal-content { transform: scale(1) translateY(0); }
.modal-header {
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.modal-header h3 i { color: var(--accent); }
.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--surface-alt);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-body { padding: 1.75rem; }
.modal-footer {
    padding: 1rem 1.75rem 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ===== FORM ===== */
.form-group { margin-bottom: 1.25rem; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-input, .form-select {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text);
    background: var(--surface);
    transition: var(--transition);
    outline: none;
}
.form-input:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(44,82,130,0.1);
}
.form-input::placeholder { color: var(--text-muted); }

/* ===== FILE UPLOAD AREA ===== */
.file-upload-area {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    transition: var(--transition);
    background: var(--surface-alt);
    cursor: pointer;
}
.file-upload-area:hover { border-color: var(--primary-light); background: var(--primary-50); }
.file-upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.file-upload-area .upload-icon { font-size: 1.5rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.file-upload-area .upload-text { font-size: 0.75rem; color: var(--text-muted); }
.file-upload-area .upload-text strong { color: var(--primary-light); }
.file-upload-area.has-file { border-color: var(--success); border-style: solid; background: var(--success-bg); }
.file-upload-area.has-file .upload-icon { color: var(--success); }
.file-upload-area .file-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--success);
    margin-top: 0.25rem;
    word-break: break-all;
}
.file-upload-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.current-file {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: var(--surface-alt);
    border-radius: 8px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 0.4rem;
}
.current-file i { font-size: 0.8rem; }
.current-file .remove-file {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0.2rem;
    opacity: 0.6;
    transition: var(--transition);
}
.current-file .remove-file:hover { opacity: 1; }

/* ===== ADMIN PAGE ===== */
.admin-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    overflow: hidden;
}
.admin-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-alt);
}
.admin-card-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.admin-card-body { padding: 1.5rem; }
.admin-list { list-style: none; }
.admin-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 0.4rem;
    transition: var(--transition);
}
.admin-list-item:hover { background: var(--surface-alt); }
.admin-list-item .admin-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.admin-list-item .admin-info { flex: 1; min-width: 0; }
.admin-list-item .admin-name { font-weight: 600; font-size: 0.85rem; color: var(--text); }
.admin-list-item .admin-email { font-size: 0.72rem; color: var(--text-muted); }
.admin-list-item .wp-admin-tag {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    background: var(--accent-50);
    color: var(--accent-dark);
    border-radius: var(--radius-full);
    border: 1px solid rgba(198,146,20,0.2);
}
.add-admin-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}
.add-admin-form .form-group { flex: 1; margin-bottom: 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .topbar-right { 
        display: none;
        position: absolute;
        top: var(--topbar-h);
        left: 0;
        right: 0;
        background: var(--primary-dark);
        flex-direction: column;
        padding: 0.75rem;
        gap: 0.25rem;
        box-shadow: var(--shadow-lg);
    }
    .topbar-right.active { display: flex; }
    .topbar-toggle { display: block; }
    .topbar-link, .topbar-user { width: 100%; justify-content: flex-start; }
    
    .main-container { padding-left: 1rem; padding-right: 1rem; }
    .page-header h1 { font-size: 1.35rem; }
    .tab-btn { min-width: 140px; font-size: 0.78rem; padding: 0.85rem 1rem; }
    .tab-toolbar { flex-direction: column; gap: 0.75rem; align-items: stretch; }
    
    .data-table { display: block; overflow-x: auto; }
    .data-table thead th, .data-table tbody td { padding: 0.75rem 1rem; font-size: 0.78rem; }
    
    .file-upload-row { grid-template-columns: 1fr; }
    .add-admin-form { flex-direction: column; }
    .modal-content { max-width: 100%; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease; }
.slide-up { animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
