/**
 * Custom Theme - Red/Orange/Green/Blue Color Scheme
 * สีธีม: แดง-ส้ม-เขียว-ฟ้า
 */

/* ========== Color Variables ========== */
:root {
    --primary-color: #e74c3c;      /* สีแดง */
    --secondary-color: #f39c12;    /* สีส้ม */
    --success-color: #27ae60;      /* สีเขียว */
    --info-color: #3498db;         /* สีฟ้า */
    --danger-color: #c0392b;       /* สีแดงเข้ม */
    --warning-color: #e67e22;      /* สีส้มเข้ม */
}

/* ========== Navbar ========== */
/* ลบออก - ใช้ theme-variables.css แทน */

/* ========== Sidebar ========== */
/* ลบออก - ใช้ theme-variables.css แทน */

/* ========== Buttons ========== */
.btn-primary {
    background: #e74c3c !important;
    border: none !important;
}

.btn-primary:hover {
    background: #c0392b !important;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.btn-success {
    background: #27ae60 !important;
    border: none !important;
}

.btn-success:hover {
    background: #229954 !important;
}

.btn-info {
    background: #3498db !important;
    border: none !important;
}

.btn-info:hover {
    background: #2980b9 !important;
}

.btn-warning {
    background: #f39c12 !important;
    border: none !important;
    color: white !important;
}

.btn-warning:hover {
    background: #e67e22 !important;
}

/* ========== Info Boxes (Dashboard Cards) ========== */
.info-box {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-radius: 10px;
    transition: transform 0.3s;
}

.info-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.info-box-icon.bg-info {
    background: #3498db !important;
}

.info-box-icon.bg-success {
    background: #27ae60 !important;
}

.info-box-icon.bg-warning {
    background: #f39c12 !important;
}

.info-box-icon.bg-danger {
    background: #e74c3c !important;
}

/* ========== Small Boxes ========== */
.small-box.bg-info {
    background: #3498db !important;
}

.small-box.bg-success {
    background: #27ae60 !important;
}

.small-box.bg-warning {
    background: #f39c12 !important;
}

.small-box.bg-danger {
    background: #e74c3c !important;
}

/* ========== Cards ========== */
.card {
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: box-shadow 0.3s;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.card-header {
    background: #3498db;
    color: white;
    border-bottom: none;
    border-radius: 10px 10px 0 0 !important;
}

.card-primary:not(.card-outline) > .card-header {
    background: #e74c3c;
}

.card-success:not(.card-outline) > .card-header {
    background: #27ae60;
}

.card-warning:not(.card-outline) > .card-header {
    background: #f39c12;
}

.card-info:not(.card-outline) > .card-header {
    background: #3498db;
}

/* ========== Badges ========== */
.badge-primary {
    background: #e74c3c !important;
}

.badge-success {
    background: #27ae60 !important;
}

.badge-info {
    background: #3498db !important;
}

.badge-warning {
    background: #f39c12 !important;
    color: white !important;
}

.badge-danger {
    background: #e74c3c !important;
}

/* ========== Links ========== */
a {
    color: #e74c3c;
}

a:hover {
    color: #c0392b;
}

/* ========== Progress Bars ========== */
.progress-bar.bg-primary {
    background: #e74c3c !important;
}

.progress-bar.bg-success {
    background: #27ae60 !important;
}

.progress-bar.bg-info {
    background: #3498db !important;
}

.progress-bar.bg-warning {
    background: #f39c12 !important;
}

/* ========== Tables ========== */
.table thead th {
    background: #3498db;
    color: white;
    border: none;
}

.table-hover tbody tr:hover {
    background: rgba(52, 152, 219, 0.1);
}

/* ========== Pagination ========== */
.pagination .page-item.active .page-link {
    background: #e74c3c !important;
    border-color: #e74c3c !important;
}

.pagination .page-link {
    color: #e74c3c;
}

.pagination .page-link:hover {
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
}

/* ========== Forms ========== */
.form-control:focus {
    border-color: #e74c3c;
    box-shadow: 0 0 0 0.2rem rgba(231, 76, 60, 0.25);
}

.custom-control-input:checked ~ .custom-control-label::before {
    background: #e74c3c;
    border-color: #e74c3c;
}

/* ========== Login Page ========== */
.login-page {
    background: #3498db !important;
}

.login-box .card {
    border-radius: 15px;
}

/* ========== Charts ========== */
.chart-container canvas {
    border-radius: 10px;
}

/* ========== Animations ========== */
@keyframes gradient-shift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.gradient-animate {
    background-size: 200% 200%;
    animation: gradient-shift 3s ease infinite;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #e74c3c;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #c0392b;
}

/* ========== Page Loader (NEW) ========== */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    background: rgba(52, 152, 219, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#page-loader .loader-content {
    text-align: center;
    color: white;
}

#page-loader .loader-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255,255,255,0.3);
    border-top: 5px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

#page-loader .loader-text {
    font-size: 1.2rem;
    font-weight: 600;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

/* ========== Top Progress Bar ========== */
#top-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: #e74c3c;
    z-index: 999999;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.8);
}

/* ========== Loading Screen ========== */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: #3498db;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

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

.preloader-logo {
    font-size: 4rem;
    color: white;
    margin-bottom: 20px;
    animation: pulse 1.5s ease-in-out infinite;
}

.preloader-text {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255,255,255,0.3);
    border-top: 5px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.loading-dots {
    display: inline-block;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* ========== Custom Alert/Toast System ========== */
.custom-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    min-width: 300px;
    max-width: 400px;
    z-index: 9998;
    animation: slideInRight 0.4s ease-out;
}

.custom-toast.toast-hide {
    animation: slideOutRight 0.4s ease-in forwards;
}

.custom-toast .toast-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 20px;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.custom-toast .toast-icon {
    font-size: 2rem;
    margin-right: 15px;
    flex-shrink: 0;
}

.custom-toast .toast-body {
    flex: 1;
}

.custom-toast .toast-title {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.custom-toast .toast-message {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

.custom-toast .toast-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.custom-toast .toast-close:hover {
    opacity: 1;
}

.custom-toast .toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    width: 100%;
    background: rgba(0,0,0,0.1);
    animation: progressBar 3s linear forwards;
}

/* Toast Types */
.custom-toast.toast-success .toast-icon { color: #27ae60; }
.custom-toast.toast-success .toast-progress { background: #27ae60; }

.custom-toast.toast-error .toast-icon { color: #e74c3c; }
.custom-toast.toast-error .toast-progress { background: #e74c3c; }

.custom-toast.toast-warning .toast-icon { color: #f39c12; }
.custom-toast.toast-warning .toast-progress { background: #f39c12; }

.custom-toast.toast-info .toast-icon { color: #3498db; }
.custom-toast.toast-info .toast-progress { background: #3498db; }

/* Animations */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes progressBar {
    from { width: 100%; }
    to { width: 0%; }
}

/* ========== Custom Confirm Dialog ========== */
.custom-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.custom-dialog {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    max-width: 450px;
    width: 90%;
    animation: scaleIn 0.3s ease-out;
    overflow: hidden;
}

.custom-dialog .dialog-header {
    padding: 25px;
    text-align: center;
}

.custom-dialog .dialog-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.custom-dialog.dialog-success .dialog-icon { color: #27ae60; }
.custom-dialog.dialog-error .dialog-icon { color: #e74c3c; }
.custom-dialog.dialog-warning .dialog-icon { color: #f39c12; }
.custom-dialog.dialog-info .dialog-icon { color: #3498db; }
.custom-dialog.dialog-question .dialog-icon { color: #9b59b6; }

.custom-dialog .dialog-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.custom-dialog .dialog-message {
    font-size: 1rem;
    color: #666;
    line-height: 1.6;
}

.custom-dialog .dialog-footer {
    padding: 20px 25px;
    background: #f8f9fa;
    text-align: center;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.custom-dialog .dialog-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 120px;
}

.custom-dialog .dialog-btn-confirm {
    background: #27ae60;
    color: white;
}

.custom-dialog .dialog-btn-confirm:hover {
    background: #229954;
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.4);
    transform: translateY(-2px);
}

.custom-dialog .dialog-btn-cancel {
    background: #6c757d;
    color: white;
}

.custom-dialog .dialog-btn-cancel:hover {
    background: #5a6268;
}

.custom-dialog .dialog-btn-danger {
    background: #e74c3c;
    color: white;
}

.custom-dialog .dialog-btn-danger:hover {
    background: #c0392b;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
    transform: translateY(-2px);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ========== AJAX Loading State ========== */
.content-wrapper.ajax-loading {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.content-wrapper.ajax-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 4px solid rgba(231, 76, 60, 0.2);
    border-top: 4px solid #e74c3c;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 1000;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .main-header.navbar {
        background: #3498db !important;
    }

    .preloader-logo {
        font-size: 3rem;
    }

    .preloader-text {
        font-size: 1.2rem;
    }

    .custom-toast {
        top: 70px;
        right: 10px;
        left: 10px;
        min-width: auto;
    }

    .custom-dialog {
        width: 95%;
    }

    .custom-dialog .dialog-footer {
        flex-direction: column;
    }

    .custom-dialog .dialog-btn {
        width: 100%;
    }
}
