:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --bg-dark: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-hover: rgba(51, 65, 85, 0.8);
    --font-family: 'Kanit', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Dynamic Background Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    animation-delay: 0s;
}

.blob-2 {
    bottom: -20%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
    animation-delay: -5s;
}

.blob-3 {
    top: 30%;
    left: 40%;
    width: 40vw;
    height: 40vw;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    opacity: 0.3;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -50px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
    100% { transform: translate(0, 0) scale(1); }
}

/* App Container */
.app-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Glass Header */
.glass-header {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-area h1 {
    font-size: 1.75rem;
    font-weight: 600;
    background: linear-gradient(135deg, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.stats-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Search and Filters */
.search-filter-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-bar {
    position: relative;
    width: 100%;
}

.search-bar svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 1rem 1rem 3rem;
    color: var(--text-main);
    font-family: var(--font-family);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.filters {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 140px;
}

select {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: var(--font-family);
    font-size: 0.9rem;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

select:focus {
    outline: none;
    border-color: var(--secondary);
}

.btn-icon, .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-primary {
    background: var(--primary);
    border: none;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    margin-top: 1rem;
}

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

.btn-add-cart {
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.4);
    color: #34d399;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-add-cart:hover {
    background: #34d399;
    color: #000;
}

.btn-add-cart.added {
    background: #10b981;
    border-color: #10b981;
    color: #000;
    cursor: default;
}

.btn-add-cart.added:hover {
    background: #10b981;
    color: #000;
    transform: none;
    box-shadow: none;
}

.btn-add-cart.locked {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
    cursor: help;
}

.btn-add-cart.locked:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Notice Box */
.notice-box {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    color: #fcd34d;
    font-size: 0.95rem;
    line-height: 1.5;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    animation: fadeIn 0.3s ease;
}

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

/* Grid Layout */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Book Cards */
.book-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    backdrop-filter: blur(10px);
}

.book-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
    background: var(--card-hover);
}

.card-image {
    width: 100%;
    height: 180px;
    background-color: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    border-bottom: 1px solid var(--glass-border);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.book-card:hover .card-image img {
    transform: scale(1.05);
}

.no-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.card-content {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.badge-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-main);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 10;
}

.book-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-meta {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.meta-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.meta-icon {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.price-tag {
    margin-top: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #34d399; /* Emerald */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    padding: 1rem;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 24px;
    position: relative;
    transform: translateY(0) scale(1);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal {
    transform: translateY(20px) scale(0.95);
}

.glass-panel {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.8);
    transform: rotate(90deg);
}

.modal-content {
    padding: 2.5rem;
}

.detail-layout {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.detail-image-box {
    flex: 1;
    min-width: 250px;
    background: #0f172a;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--glass-border);
}

.detail-image-box img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.detail-info {
    flex: 2;
    min-width: 300px;
}

.detail-title {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.detail-type {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 0.25rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.detail-item {
    background: rgba(0,0,0,0.2);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
}

.detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.detail-value {
    font-weight: 500;
    font-size: 0.95rem;
}

.detail-price {
    grid-column: 1 / -1;
    background: rgba(52, 211, 153, 0.1);
    border-color: rgba(52, 211, 153, 0.3);
}

.detail-price .detail-value {
    color: #34d399;
    font-size: 1.5rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 3rem;
    flex-wrap: wrap;
}

.page-btn {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
    font-weight: 500;
}

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

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading & Empty States */
.loading-state, .no-results {
    text-align: center;
    padding: 5rem 0;
    grid-column: 1 / -1;
}

.hidden {
    display: none !important;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem auto;
}

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

.no-results svg {
    color: var(--text-muted);
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Cart Styles */
.modal-header-cart {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2.5rem;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.5);
    border-radius: 24px 24px 0 0;
}

.cart-items-container {
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 1rem;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-bottom: 1rem;
    gap: 1rem;
}

.cart-item-info {
    flex: 1;
}

.cart-item-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.cart-item-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-remove {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: #ef4444;
    color: white;
}

.cart-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    margin-top: 1rem;
}

.cart-summary-text {
    font-size: 1.25rem;
}

footer {
    text-align: center;
    padding: 3rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--glass-border);
    margin-top: 3rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .detail-layout {
        flex-direction: column;
    }
}

/* Form Controls */
.form-control {
    background: rgba(15,23,42,0.6);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-family: var(--font-family);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255,255,255,0.2);
    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%;
}

/* Settings Button */
.settings-trigger {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.settings-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Modal Guideline Box */
.obec-guideline-box {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-bottom: 1.5rem;
}

/* Grade Settings List inside Modal */
.grade-settings-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.grade-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    transition: background 0.2s;
}

.grade-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.grade-label {
    font-weight: 500;
    font-size: 0.95rem;
}

.grade-rate {
    color: #3b82f6;
    font-size: 0.9rem;
    text-align: right;
    padding-right: 1rem;
}

.grade-row input[type="number"] {
    width: 100%;
    text-align: center;
    padding: 0.4rem;
}

/* Validation Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    animation: fadeIn 0.3s ease;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-warn {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

.budget-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.budget-stat-item {
    text-align: center;
}

.budget-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.budget-stat-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.progress-bar-bg {
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s, background-color 0.3s;
}

/* ============================================================
   Choices.js Dark Glassmorphism Theme Override
   ============================================================ */
.choices {
    font-family: var(--font-family) !important;
    font-size: 0.9rem !important;
}

.choices__inner {
    background: rgba(255,255,255,0.07) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 10px !important;
    padding: 0.3rem 0.5rem !important;
    min-height: 38px !important;
    color: white !important;
    box-shadow: none !important;
    cursor: pointer !important;
}

.choices__list--multiple .choices__item {
    background: rgba(59, 130, 246, 0.3) !important;
    border: 1px solid rgba(59, 130, 246, 0.5) !important;
    border-radius: 6px !important;
    color: #e0f2fe !important;
    font-size: 0.8rem !important;
    margin: 2px !important;
}

.choices__list--multiple .choices__item.is-highlighted {
    background: rgba(59, 130, 246, 0.5) !important;
}

.choices__list--multiple .choices__item .choices__button {
    border-left: 1px solid rgba(255,255,255,0.3) !important;
    filter: invert(1) !important;
    opacity: 0.7 !important;
}

.choices__list--dropdown {
    background: #1e293b !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 12px !important;
    margin-top: 4px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4) !important;
    z-index: 9999 !important;
}

.choices__list--dropdown .choices__list {
    max-height: 200px !important;
}

.choices__list--dropdown .choices__item {
    color: var(--text-secondary) !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.88rem !important;
}

.choices__list--dropdown .choices__item.is-highlighted,
.choices__list--dropdown .choices__item:hover {
    background: rgba(59,130,246,0.2) !important;
    color: white !important;
}

.choices__input {
    background: transparent !important;
    color: white !important;
    font-family: var(--font-family) !important;
}

.choices[data-type*="select-multiple"] .choices__inner {
    cursor: pointer !important;
}

.choices__placeholder {
    color: rgba(255,255,255,0.4) !important;
    opacity: 1 !important;
}

/* Make filter groups wider for multi-select tags */
.filters .filter-group {
    min-width: 190px !important;
    flex: 1 !important;
}

.choices__list--dropdown .choices__input {
    background: rgba(255,255,255,0.05) !important;
    border-bottom: 1px solid var(--glass-border) !important;
    color: white !important;
    font-family: var(--font-family) !important;
    padding: 0.5rem 1rem !important;
}
