/**
 * main.css - ไฟล์ CSS หลักของระบบบัญชีครัวเรือน
 * 
 * @author Devtaiban www.Kruwirat.com
 */

 :root {
    /* สีหลัก */
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --info-color: #3498db;
    --light-color: #f5f5f5;
    --dark-color: #343a40;
    
    /* สีพื้นหลัง */
    --light-bg: #f8f9fa;
    --dark-bg: #121212;
    --dark-surface: #1e1e1e;
    --dark-card: #252525;
    
    /* สีข้อความ */
    --light-text: #212529;
    --dark-text: #e0e0e0;
    --muted-text: #6c757d;
    
    /* ค่าอื่นๆ */
    --border-radius: 5px;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --box-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --transition-speed: 0.3s;
}

/* ตั้งค่าพื้นฐาน */
body {
    font-family: 'Kodchasan', sans-serif;
    background-color: var(--light-bg);
    color: var(--light-text);
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: 56px; /* สำหรับ fixed navbar */
}

/* โหมด Dark Mode */
[data-bs-theme="dark"] {
    --bs-body-bg: var(--dark-bg);
    --bs-body-color: var(--dark-text);
}

[data-bs-theme="dark"] .card {
    background-color: var(--dark-card);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .table {
    --bs-table-color: var(--dark-text);
    --bs-table-bg: var(--dark-card);
    --bs-table-border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .modal-content {
    background-color: var(--dark-surface);
    color: var(--dark-text);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--dark-bg);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--dark-text);
}

[data-bs-theme="dark"] .input-group-text {
    background-color: #2c3e50;
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--dark-text);
}

/* Navbar */
.navbar {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: background-color var(--transition-speed) ease;
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    width: 240px;
    z-index: 100;
    padding-top: 20px;
    overflow-y: auto;
    background-color: var(--light-bg);
    transition: all var(--transition-speed) ease;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .sidebar {
    background-color: var(--dark-surface);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.1);
}

.sidebar .nav-link {
    padding: 0.75rem 1rem;
    color: var(--light-text);
    border-radius: var(--border-radius);
    margin: 0.2rem 1rem;
    transition: all var(--transition-speed) ease;
}

[data-bs-theme="dark"] .sidebar .nav-link {
    color: var(--dark-text);
}

.sidebar .nav-link:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

.sidebar .nav-link.active {
    background-color: rgba(52, 152, 219, 0.2);
    color: var(--primary-color);
    font-weight: 500;
}

.sidebar .nav-link i {
    margin-right: 0.5rem;
    width: 20px;
    text-align: center;
}

/* Main content */
.content {
    margin-left: 240px;
    padding: 2rem;
    transition: all var(--transition-speed) ease;
}

/* Cards */
.card {
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    border: none;
    margin-bottom: 1.5rem;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--box-shadow-lg);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 1rem 1.25rem;
}

[data-bs-theme="dark"] .card-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Buttons */
.btn {
    border-radius: var(--border-radius);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-speed) ease;
}

.btn::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: -100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: all 0.4s ease;
}

.btn:hover::after {
    left: 100%;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-secondary {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-warning {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
}

.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-info {
    background-color: var(--info-color);
    border-color: var(--info-color);
}

/* Forms */
.form-control, .form-select {
    border-radius: var(--border-radius);
    padding: 0.5rem 0.75rem;
    transition: all var(--transition-speed) ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.input-group-text {
    border-radius: var(--border-radius);
}

/* Tables */
.table {
    vertical-align: middle;
}

.table th {
    font-weight: 600;
    border-top: none;
}

.table td {
    padding: 0.75rem;
}

/* Alerts */
.alert {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: var(--box-shadow);
}

/* Badges */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* Progress bars */
.progress {
    border-radius: var(--border-radius);
    background-color: rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .progress {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Theme Switch */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
}

.theme-switch {
    display: inline-block;
    position: relative;
    width: 60px;
    height: 34px;
    margin: 0 10px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.theme-switch .slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.theme-switch input:checked + .slider {
    background-color: var(--primary-color);
}

.theme-switch input:checked + .slider:before {
    transform: translateX(26px);
}

.theme-switch .sun-icon,
.theme-switch .moon-icon {
    position: absolute;
    top: 7px;
    font-size: 18px;
    transition: .4s;
}

.theme-switch .sun-icon {
    left: 7px;
    color: #f1c40f;
    opacity: 1;
}

.theme-switch .moon-icon {
    right: 7px;
    color: #f1c40f;
    opacity: 0;
}

.theme-switch input:checked ~ .sun-icon {
    opacity: 0;
}

.theme-switch input:checked ~ .moon-icon {
    opacity: 1;
}

/* Footer */
.footer {
    margin-top: auto;
    padding: 1.5rem 0;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translate3d(0, -20px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Notification dropdown */
.notification-dropdown .dropdown-menu {
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    animation: fadeInDown 0.3s ease;
}

.notification-dropdown .dropdown-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    white-space: normal;
}

[data-bs-theme="dark"] .notification-dropdown .dropdown-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.notification-dropdown .dropdown-item:last-child {
    border-bottom: none;
}

/* Profile picture */
.profile-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    margin-right: 10px;
}

/* Responsive styles */
@media (max-width: 991.98px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
        padding-top: 0;
    }
    
    .content {
        margin-left: 0;
        padding: 1rem;
    }
    
    .notification-dropdown .dropdown-menu {
        width: 290px;
    }
}

@media (max-width: 767.98px) {
    .sidebar {
        display: none;
    }
    
    .sidebar.show {
        display: block;
        width: 100%;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    
    .content {
        margin-left: 0;
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .table-responsive {
        margin-bottom: 0;
    }
}

@media (max-width: 575.98px) {
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .notification-dropdown .dropdown-menu {
        width: 260px;
    }
}

/* เสริมความสวยงาม */

/* สีกราฟ */
.chart-container {
    position: relative;
    margin: 0 auto;
}

/* ลูกเล่นข้อความ */
.highlight {
    background: linear-gradient(120deg, rgba(255, 223, 0, 0.4) 0%, rgba(255, 223, 0, 0.01) 100%);
    padding: 0 0.25em;
    border-radius: 3px;
}

/* ลูกเล่นสำหรับการ์ด */
.card-hover-overlay {
    position: relative;
    overflow: hidden;
}

.card-hover-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0);
    transition: background 0.3s ease;
}

.card-hover-overlay:hover::after {
    background: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .card-hover-overlay:hover::after {
    background: rgba(0, 0, 0, 0.1);
}

/* สีพื้นหลังสำหรับหมวดหมู่และบัญชี */
.category-badge, .account-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35em 0.65em;
    border-radius: 50rem;
    color: white;
    font-weight: 500;
}

.category-badge i, .account-badge i {
    margin-right: 0.35em;
}

/* Loader */
.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--primary-color);
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ลูกเล่นสำหรับสถิติ */
.stat-card {
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
    text-align: left;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-card .stat-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.stat-card .stat-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 3rem;
    opacity: 0.2;
}

.stat-card .stat-change {
    font-size: 0.875rem;
    display: flex;
    align-items: center;
}

.stat-card .stat-change.positive {
    color: var(--success-color);
}

.stat-card .stat-change.negative {
    color: var(--danger-color);
}

.stat-card .stat-change i {
    margin-right: 0.25rem;
}

/* นำทางขั้นตอน (Stepper) */
.stepper {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
}

.stepper-item {
    flex: 1;
    text-align: center;
    position: relative;
}

.stepper-item:not(:last-child)::after {
    content: '';
    height: 2px;
    background-color: #e9ecef;
    position: absolute;
    top: 24px;
    left: 50%;
    right: -50%;
    z-index: 0;
}

[data-bs-theme="dark"] .stepper-item:not(:last-child)::after {
    background-color: #343a40;
}

.stepper-item.active:not(:last-child)::after,
.stepper-item.completed:not(:last-child)::after {
    background-color: var(--primary-color);
}

.stepper-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    margin: 0 auto 10px;
}

[data-bs-theme="dark"] .stepper-circle {
    background-color: #343a40;
}

.stepper-circle.active {
    background-color: var(--primary-color);
    color: white;
}

.stepper-circle.completed {
    background-color: var(--success-color);
    color: white;
}

/* ปุ่มกลม */
.btn-circle {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-circle.btn-sm {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
}

.btn-circle.btn-lg {
    width: 50px;
    height: 50px;
    font-size: 1.25rem;
}

/* เส้นคั่นแนวตั้ง */
.vr {
    display: inline-block;
    align-self: stretch;
    width: 1px;
    min-height: 1em;
    background-color: currentColor;
    opacity: 0.25;
}

/* ประกายเรืองแสง */
.glow-on-hover {
    position: relative;
    overflow: hidden;
}

.glow-on-hover::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: -100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: all 0.6s ease;
}

.glow-on-hover:hover::before {
    left: 100%;
}