/**
 * e-DOCTracking Theme CSS
 * ไฟล์ CSS กลางสำหรับทั้งระบบ
 * Version: 1.0.0
 */

/* ===========================
   1. Global Styles
   =========================== */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;600;700&display=swap');

* {
    font-family: 'Sarabun', sans-serif;
}

body {
    font-family: 'Sarabun', sans-serif;
    background: #f5f5f5;
    display: flex;
    min-height: 100vh;
    margin: 0;
}

/* ===========================
   2. Sidebar Styles
   =========================== */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: left 0.3s;
}

.sidebar-header {
    padding: 20px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h5 {
    margin: 0;
    font-weight: bold;
    font-size: 1.5rem;
}

.sidebar-header small {
    opacity: 0.9;
    font-size: 0.85rem;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 15px 0;
}

.sidebar-menu li {
    padding: 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: white;
    text-decoration: none;
    transition: all 0.3s;
}

.sidebar-menu a:hover {
    background: rgba(255,255,255,0.1);
    padding-left: 25px;
}

.sidebar-menu a.active {
    background: rgba(255,255,255,0.2);
    border-left: 4px solid #ffd700;
    font-weight: bold;
}

.sidebar-menu .badge {
    margin-left: auto;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 12px;
}

.sidebar-menu .badge-red {
    background: #ff4757;
    color: white;
}

.sidebar-menu .badge-yellow {
    background: #f39c12;
    color: white;
}

.sidebar-menu .badge-green {
    background: #27ae60;
    color: white;
}

.sidebar-menu .badge-blue {
    background: #3498db;
    color: white;
}

.sidebar-menu .badge-purple {
    background: #9b59b6;
    color: white;
}

.sidebar-menu i {
    width: 25px;
    margin-right: 10px;
}

/* ===========================
   3. Main Content
   =========================== */
.main-content {
    margin-left: 280px;
    flex: 1;
    padding: 0;
    transition: margin-left 0.3s ease-in-out;
}

/* ===========================
   4. Navbar Styles
   =========================== */
.navbar {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 15px 30px;
}

.navbar-brand {
    color: #667eea !important;
    font-weight: bold;
    font-size: 1.3rem;
}

.user-info {
    color: #333;
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid white;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.3);
    color: white;
}

/* ===========================
   5. Card Styles
   =========================== */
.card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin: 20px;
}

.card-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px 15px 0 0 !important;
    padding: 20px 25px;
}

.card-header h4 {
    margin: 0;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header .text-white {
    color: white !important;
    opacity: 0.95;
}

.card-body {
    padding: 25px;
}

.badge-count {
    background: #28a745;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    margin-left: 10px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* ===========================
   5.1 Card Header Theme (Reusable)
   - ใช้ class card-header-flex สำหรับ layout แบบ 2 ฝั่ง
   - ฝั่งซ้าย: Icon + Title + Badge
   - ฝั่งขวา: Action buttons
   =========================== */
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header-flex .card-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.card-header-flex .card-header-left h4 {
    margin: 0;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.card-header-flex .card-header-left h4 i {
    font-size: 1.2rem;
}

.card-header-flex .card-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.card-header-flex .card-header-right .btn {
    white-space: nowrap;
}

/* Responsive: stack on mobile */
@media (max-width: 576px) {
    .card-header-flex {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-header-flex .card-header-right {
        width: 100%;
        margin-top: 10px;
    }
}

/* ===========================
   6. Table Styles
   =========================== */
.table {
    margin-bottom: 0;
}

.table thead th {
    background: #e7f1ff;
    color: #333;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    padding: 15px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table thead th:hover {
    background: #d0e7ff;
}

.table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.table tbody tr:hover {
    background-color: #e9ecef !important;
    cursor: pointer;
}

.table-responsive {
    border-radius: 10px;
    overflow: hidden;
    max-height: 65vh;
    overflow-y: auto;
}

/* ===========================
   7. Status Badge Styles
   =========================== */
.badge-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

.badge-new {
    background: #ffc107;
    color: #000;
}

.badge-pending {
    background: #17a2b8;
    color: white;
}

.badge-completed {
    background: #28a745;
    color: white;
}

.badge-returned {
    background: #dc3545;
    color: white;
}

.badge-inprogress {
    background: #f39c12;
    color: white;
}

/* ===========================
   8. Action Buttons
   =========================== */
.btn-action {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 3px;
    font-size: 14px;
}

.btn-view {
    background: #17a2b8;
    color: white;
}

.btn-view:hover {
    background: #138496;
    transform: scale(1.1);
}

.btn-edit {
    background: #ffc107;
    color: #000;
}

.btn-edit:hover {
    background: #e0a800;
    transform: scale(1.1);
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* ===========================
   9. Modal Styles
   =========================== */
.modal-content {
    border-radius: 15px;
    border: none;
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px 15px 0 0;
    padding: 20px 25px;
}

.modal-title {
    font-weight: 700;
    font-size: 1.5rem;
}

.btn-close {
    filter: brightness(0) invert(1);
}

.form-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #ddd;
    padding: 10px 15px;
}

.form-control:focus,
.form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* ===========================
   10. Pagination
   =========================== */
.pagination {
    margin-bottom: 0;
}

.pagination .page-item.active .page-link {
    background: #667eea;
    border-color: #667eea;
    color: #ffffff !important;
    font-weight: 600;
}

.pagination .page-link {
    color: #667eea;
    font-weight: 500;
    border: 1px solid #dee2e6;
    padding: 8px 12px;
}

.pagination .page-link:hover {
    background: #f0f0f0;
    color: #667eea;
}

.pagination .page-item.disabled .page-link {
    color: #6c757d;
    background-color: #fff;
    border-color: #dee2e6;
}

/* ===========================
   11. Loading & Spinner
   =========================== */
.loading {
    text-align: center;
    padding: 50px;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* ===========================
   12. Utility Classes
   =========================== */
.text-muted {
    color: #6c757d !important;
}

.text-white {
    color: white !important;
}

.text-center {
    text-align: center;
}

/* ===========================
   13. Button Styles
   =========================== */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 8px;
    transition: all 0.3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    border: none;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* ===========================
   14. Responsive Design
   =========================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        transition: left 0.3s;
        z-index: 1000;
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .table-responsive {
        max-height: 50vh;
    }
}

/* ===========================
   15. Animation
   =========================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

/* ===========================
   16. Custom Scrollbar
   =========================== */
.table-responsive::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.table-responsive::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.table-responsive::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
    background: #555;
}
