/* ================================================
   ระบบบริหารงบสวัสดิการนักกีฬา - Stylesheet
   Premium Design with Glassmorphism & Micro-animations
   ================================================ */

/* ====== CSS Variables (Design Tokens) ====== */
:root {
    /* Primary Palette - Bright Yellow/Amber */
    --primary-color: #d97706;
    --primary-light: #f59e0b;
    --primary-lighter: #fbbf24;

    /* Accent */
    --accent-color: #eab308;
    --accent-hover: #ca8a04;
    --accent-glow: rgba(234, 179, 8, 0.35);

    /* Semantic */
    --income-color: #10b981;
    --income-bg: rgba(16, 185, 129, 0.1);
    --income-glow: rgba(16, 185, 129, 0.25);
    --expense-color: #ef4444;
    --expense-bg: rgba(239, 68, 68, 0.1);
    --expense-glow: rgba(239, 68, 68, 0.25);
    --danger-color: #ef4444;

    /* Surface */
    --bg-color: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-border: rgba(255, 255, 255, 0.6);
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.2);

    /* Text */
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-light: #cbd5e1;

    /* Border & Shadow */
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 30px rgba(234, 179, 8, 0.15);

    /* Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.875rem;
    --radius-lg: 1.25rem;
    --radius-xl: 1.5rem;

    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    /* Sidebar */
    --sidebar-width: 280px;

    /* Font */
    --font-heading: 'Kanit', sans-serif;
    --font-body: 'Sarabun', sans-serif;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-color);
    background: var(--bg-color);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(234, 179, 8, 0.07) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(245, 158, 11, 0.05) 0%, transparent 60%);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.3;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

/* ====== Global Loader ====== */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

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

.spinner-wrap {
    text-align: center;
}

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

.spinner-text {
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-heading);
    font-size: 1rem;
    letter-spacing: 0.5px;
}

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

/* ====== Toast Notifications ====== */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    background: white;
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 300px;
    max-width: 420px;
    animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 4px solid transparent;
    backdrop-filter: blur(12px);
}

.toast.success {
    border-left-color: var(--income-color);
    background: linear-gradient(135deg, #ecfdf5, white);
}

.toast.success i {
    color: var(--income-color);
}

.toast.error {
    border-left-color: var(--expense-color);
    background: linear-gradient(135deg, #fef2f2, white);
}

.toast.error i {
    color: var(--expense-color);
}

.toast.info {
    border-left-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff, white);
}

.toast.info i {
    color: #3b82f6;
}

.toast.removing {
    animation: slideOutRight 0.3s ease-in forwards;
}

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

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

/* ====== Layout ====== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ====== Sidebar ====== */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--border-color);
    color: var(--text-color);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform var(--transition-normal);
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-wrapper {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-color), #f97316);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.sidebar-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
    color: var(--text-color);
}

.sidebar-header h3 small {
    display: block;
    font-size: 0.7rem;
    font-weight: 300;
    color: var(--text-muted);
    margin-top: 2px;
}

.close-sidebar {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: color var(--transition-fast);
}

.close-sidebar:hover {
    color: var(--text-color);
}

/* Nav Links */
.nav-links {
    list-style: none;
    padding: 1rem 0.75rem;
    flex: 1;
}

.nav-links li {
    margin-bottom: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 0;
    background: var(--primary-color);
    border-radius: 0 4px 4px 0;
    transition: height var(--transition-fast);
}

.nav-item:hover {
    color: var(--primary-color);
    background: rgba(245, 158, 11, 0.05);
}

.nav-item.active {
    background: rgba(245, 158, 11, 0.1);
    color: var(--primary-color);
    font-weight: 600;
}

.nav-item.active i {
    color: var(--primary-color);
}

.nav-item.active::before {
    height: 60%;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem 1.5rem 1.5rem;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.sidebar-footer .version {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.15rem 0.6rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 99px;
    font-size: 0.65rem;
    letter-spacing: 0.5px;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ====== Content Area ====== */
.content-area {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-normal);
}

/* ====== Topbar ====== */
.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    color: var(--text-color);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-color);
}

.topbar-title h2 {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-title h2 i {
    color: var(--accent-color);
    font-size: 1rem;
}

/* ====== Page Container ====== */
.page-container {
    flex: 1;
    padding: 1.5rem;
}

.page {
    display: none;
    animation: fadeIn 0.4s ease;
}

.page.active {
    display: block;
}

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

/* ====== Stats Cards ====== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* ====== Charts ====== */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 992px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.chart-container {
    position: relative;
    width: 100%;
    min-width: 0;
    height: 300px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.stat-bg-icon {
    position: absolute;
    top: -15px;
    right: -15px;
    font-size: 100px;
    opacity: 0.08;
    transform: rotate(-15deg);
    z-index: 0;
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.stat-income .stat-icon {
    background: var(--income-bg);
    color: var(--income-color);
}

.stat-income .stat-bg-icon {
    color: var(--income-color);
}

.stat-expense .stat-icon {
    background: var(--expense-bg);
    color: var(--expense-color);
}

.stat-expense .stat-bg-icon {
    color: var(--expense-color);
}

.stat-balance .stat-icon {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.stat-balance .stat-bg-icon {
    color: #3b82f6;
}

.stat-count .stat-icon {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

.stat-count .stat-bg-icon {
    color: #a855f7;
}

.stat-personal .stat-icon {
    background: rgba(249, 115, 22, 0.1);
    color: #f97316;
}

.stat-personal .stat-bg-icon {
    color: #f97316;
}

.stat-details {
    position: relative;
    z-index: 1;
}

.stat-details p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-details h3 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* ====== Cards ====== */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    transition: box-shadow var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color);
}

.card-title i {
    color: var(--accent-color);
}

/* ====== Form Styles ====== */
.form-card {
    max-width: 800px;
    margin: 0 auto;
}

.form-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--bg-color);
}

.form-section-title i {
    color: var(--accent-color);
    font-size: 0.9rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.form-grid .full-width {
    grid-column: 1 / -1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

#items-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.item-row .item-name {
    flex: 2;
}

.item-row .item-qty,
.item-row .item-price {
    flex: 1;
}

.item-row .btn-remove-item {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: none;
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

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

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.form-group label i {
    color: var(--accent-color);
    font-size: 0.8rem;
}

.text-danger {
    color: var(--danger-color);
}

.text-muted {
    color: var(--text-muted);
}

.text-center {
    text-align: center;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
select,
textarea {
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 0.7rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    color: var(--text-color);
    outline: none;
    transition: all var(--transition-fast);
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea {
    min-height: 80px;
    resize: vertical;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.5L1 3.5h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

.form-divider {
    border: none;
    border-top: 2px solid var(--bg-color);
    margin: 1.75rem 0;
}

/* Type Toggle */
.type-toggle-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.type-toggle {
    display: flex;
    background: var(--bg-color);
    border-radius: 99px;
    padding: 4px;
    position: relative;
    gap: 0;
    border: 1px solid var(--border-color);
}

.type-btn {
    padding: 0.65rem 1.75rem;
    border: none;
    background: none;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 99px;
    transition: all var(--transition-fast);
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.type-btn.active {
    color: white;
}

.type-btn[data-type="expense"].active ~ .type-slider,
.type-btn[data-type="expense"].active {
    /* Default state - expense active */
}

.type-slider {
    position: absolute;
    top: 4px;
    left: 4px;
    height: calc(100% - 8px);
    width: calc(50% - 4px);
    background: var(--expense-color);
    border-radius: 99px;
    transition: all var(--transition-normal);
    z-index: 1;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.3);
}

.type-toggle.income-active .type-slider {
    transform: translateX(100%);
    background: var(--income-color);
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

/* ====== Upload Area ====== */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: rgba(241, 245, 249, 0.5);
    margin-bottom: 1.5rem;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--accent-color);
    background: rgba(245, 158, 11, 0.03);
    box-shadow: 0 0 20px var(--accent-glow);
}

.upload-placeholder i {
    font-size: 2.5rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    display: block;
    animation: floatUpDown 3s ease-in-out infinite;
}

@keyframes floatUpDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.upload-placeholder p {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.upload-placeholder small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.upload-preview {
    position: relative;
    max-width: 400px;
    margin: 0 auto;
}

.upload-preview img {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-height: 300px;
    object-fit: contain;
}

.btn-remove-image {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 1.5rem 1rem;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-remove-image:hover {
    background: var(--danger-color);
    transform: scale(1.05);
}

/* ====== Buttons ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), #f97316);
    color: white;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

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

.btn-outline:hover {
    background: var(--bg-color);
    border-color: var(--text-muted);
    color: var(--text-color);
}

.btn-lg {
    padding: 0.8rem 2rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* ====== Tables ====== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    min-width: 700px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
}

.data-table thead th {
    background: var(--primary-color);
    color: rgba(255, 255, 255, 0.9);
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.8rem;
    padding: 0.75rem 1rem;
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 5;
}

.data-table thead th:first-child {
    border-radius: var(--radius-md) 0 0 0;
}

.data-table thead th:last-child {
    border-radius: 0 var(--radius-md) 0 0;
}

.data-table tbody td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: rgba(245, 158, 11, 0.03);
}

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

/* Type Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.7rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-income {
    background: var(--income-bg);
    color: var(--income-color);
}

.badge-expense {
    background: var(--expense-bg);
    color: var(--expense-color);
}

.badge-personal {
    background: rgba(249, 115, 22, 0.1);
    color: #ea580c;
}

.badge-pending {
    background: rgba(234, 179, 8, 0.12);
    color: #a16207;
}

/* Team Color Dots */
.team-dot {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
}

.team-dot::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.team-dot[data-team="สีแดง"]::before { background: #ef4444; }
.team-dot[data-team="สีน้ำเงิน"]::before { background: #3b82f6; }
.team-dot[data-team="สีเหลือง"]::before { background: #eab308; }
.team-dot[data-team="สีเขียว"]::before { background: #22c55e; }
.team-dot[data-team="สีชมพู"]::before { background: #ec4899; }
.team-dot[data-team="สีม่วง"]::before { background: #a855f7; }
.team-dot[data-team="สีส้ม"]::before { background: #f97316; }
.team-dot[data-team="สีขาว"]::before { background: #94a3b8; box-shadow: inset 0 0 0 1px #cbd5e1; }
.team-dot[data-team="ส่วนกลาง"]::before { background: #6366f1; }

/* Receipt Image Link */
.receipt-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: #3b82f6;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.receipt-link:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* ====== History Filters ====== */
.history-filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.search-bar {
    flex: 1;
    min-width: 200px;
    position: relative;
}

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

.search-bar input {
    padding-left: 2.5rem;
}

.filter-select {
    min-width: 150px;
}

/* ====== Lightbox ====== */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.lightbox-overlay img {
    max-width: 90%;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* ====== Modal ====== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.3s ease;
}

.modal-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 1.25rem;
}

.modal-icon.danger {
    background: var(--expense-bg);
    color: var(--expense-color);
}

.modal-icon.success {
    background: var(--income-bg);
    color: var(--income-color);
}

.modal-card h3 {
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}

.modal-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.details-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.details-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.details-list li:last-child {
    border-bottom: none;
}

.details-list li .detail-name {
    font-weight: 500;
    color: var(--text-color);
}

.details-list li .detail-meta {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ====== Loading Button State ====== */
.btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 0.5rem;
}

/* ====== Amount Formatting ====== */
.amount-income {
    color: var(--income-color);
    font-weight: 600;
}

.amount-expense {
    color: var(--expense-color);
    font-weight: 600;
}

/* ====== Responsive ====== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .close-sidebar {
        display: flex;
    }

    .content-area {
        margin-left: 0;
    }

    body {
        font-size: 1.05rem;
    }

    .card {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }

    .chart-container {
        height: 250px;
    }

    .btn-icon {
        display: flex;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .stat-details h3 {
        font-size: 1.1rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .page-container {
        padding: 1rem;
    }

    .topbar {
        padding: 0.75rem 1rem;
    }

    .topbar-title h2 {
        font-size: 1rem;
    }

    .history-filters {
        flex-direction: column;
    }

    .filter-select {
        min-width: auto;
        width: 100%;
    }

    .toast {
        min-width: auto;
        max-width: calc(100vw - 2rem);
    }

    .toast-container {
        right: 0.75rem;
        left: 0.75rem;
        top: 0.75rem;
    }

    .type-btn {
        padding: 0.55rem 1.25rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    body {
        font-size: 1.1rem;
    }

    .card {
        padding: 1rem;
    }

    .modal-card {
        padding: 1.75rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        justify-content: center;
    }
}

/* ====== Print Styles ====== */
@media print {
    .sidebar,
    .topbar,
    .form-actions,
    .btn-icon,
    .toast-container {
        display: none !important;
    }

    .content-area {
        margin-left: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ====== Scrollbar ====== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ====== Selection ====== */
::selection {
    background: var(--accent-color);
    color: white;
}

/* ====== LOGIN OVERLAY ====== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.login-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 1.5rem auto;
    box-shadow: 0 4px 15px rgba(234, 179, 8, 0.4);
}

.login-card h2 {
    color: var(--text-color);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.login-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.login-form .form-group {
    text-align: left;
}

.login-form .form-group input {
    background: var(--bg-color);
    padding: 1rem;
    font-size: 1rem;
}

.login-form .form-group input:focus {
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.1);
}

.btn-login {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    margin-top: 1rem;
}

/* ====== USER INFO SIDEBAR ====== */
.sidebar-user {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.sidebar-user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(234, 179, 8, 0.15);
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
}

.sidebar-user-info h4 {
    font-size: 1rem;
    color: var(--text-color);
    margin: 0 0 0.25rem 0;
}

.sidebar-user-info span {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-color);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}

.nav-item.logout {
    color: var(--danger-color);
    margin-top: auto;
}

.nav-item.logout:hover {
    background: rgba(239, 68, 68, 0.1);
}
