/*
 * Professional Repair Management System
 * Modern & Clean Design with Bootstrap 5
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Sarabun:wght@400;500;600;700&display=swap');

/* ===== CSS Variables ===== */
:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #60a5fa;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --light: #f8fafc;
    --dark: #0f172a;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Sarabun', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    color: var(--dark);
    line-height: 1.6;
    font-size: 15px;
}

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

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

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

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

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

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { opacity: 1; transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

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

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

@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

/* ===== Login Page ===== */
#loginPage {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#loginPage .card {
    border: none;
    border-radius: 1.5rem;
    box-shadow: var(--shadow-xl);
    animation: fadeIn 0.6s ease;
}

#loginPage h3 {
    color: var(--primary);
    font-weight: 700;
}

/* ===== Main App ===== */
#mainApp {
    background: var(--gray-50);
    min-height: 100vh;
}

/* ===== Navbar ===== */
.navbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
    box-shadow: var(--shadow-md);
    padding: 1rem 0;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
}

/* ===== Sidebar ===== */
.list-group {
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.list-group-item {
    border: none;
    border-left: 4px solid transparent;
    padding: 1rem 1.25rem;
    transition: all 0.2s;
    background: white;
    margin-bottom: 0.125rem;
    font-weight: 500;
}

.list-group-item:hover {
    background: var(--gray-50);
    border-left-color: var(--primary-light);
    transform: translateX(4px);
}

.list-group-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-left-color: var(--primary-dark);
    color: white;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.list-group-item i {
    margin-right: 0.75rem;
    width: 20px;
}

/* ===== Cards ===== */
.card {
    border: none;
    border-radius: 1.25rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s;
    animation: fadeIn 0.5s;
    background: white;
    margin-bottom: 2rem;
}

.card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 1.5rem;
    border-radius: 1.25rem 1.25rem 0 0 !important;
}

.card-header h5 {
    margin: 0;
    font-weight: 700;
    font-size: 1.25rem;
}

.card-body {
    padding: 2rem;
}

/* ===== Form Elements ===== */
.form-label {
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.form-control,
.form-select {
    border: 2px solid var(--gray-200);
    border-radius: 0.625rem;
    padding: 0.625rem 1rem;
    transition: all 0.2s;
    font-size: 0.9375rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

.form-control-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.5rem;
}

/* ===== Mechanics Info ===== */
.mechanics-info {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    padding: 2rem;
    border-radius: 1rem;
    margin-bottom: 2rem;
    border: 2px solid #93c5fd;
    animation: slideIn 0.5s;
}

.mechanics-info h6 {
    color: var(--primary-dark);
    font-weight: 700;
    margin-bottom: 1.5rem;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mechanics-info h6::before {
    content: "👷‍♂️";
    font-size: 1.5rem;
}

.mechanics-info .form-control {
    background: white;
    border-color: #bfdbfe;
    font-weight: 500;
}

.mechanics-info .form-control:focus {
    border-color: var(--primary);
}

/* ===== Table Section ===== */
.table-section {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.table-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--gray-100);
}

.table-section-header h6 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-section-header h6::before {
    content: "🔧";
    font-size: 1.5rem;
}

.table-responsive {
    border-radius: 0.75rem;
    overflow-x: auto;
    overflow-y: auto;
    position: relative;
    transition: all 0.3s ease;
}

.table-responsive.table-normal {
    max-height: 600px;
}

.table-responsive.table-expanded {
    max-height: none;
    max-width: 100%;
    overflow-x: auto;
}

.table-responsive.table-expanded table {
    min-width: 100%;
}

.table-responsive.table-expanded .form-control-sm,
.table-responsive.table-expanded .form-select-sm {
    min-width: 120px;
}

.table-responsive.table-expanded textarea.form-control-sm {
    min-width: 200px;
}

.table-responsive.table-expanded .mechanic-select {
    min-width: 150px;
}

/* Remove fixed widths in expanded mode for better spacing */
.table-responsive.table-expanded th[style*="width"],
.table-responsive.table-expanded td[style*="width"] {
    width: auto !important;
    min-width: 100px;
}

.table-responsive.table-expanded th {
    padding: 1rem 0.75rem !important;
}

.table-responsive.table-expanded td {
    padding: 0.875rem !important;
}

.table-responsive::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 6px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 6px;
    border: 2px solid #f1f5f9;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #1e3a8a 100%);
}

.table-responsive::-webkit-scrollbar-corner {
    background: #f1f5f9;
}

/* ===== Modern Table Design ===== */
.table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
}

.table-modern thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-modern thead th {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    color: white;
    font-weight: 600;
    padding: 1rem 0.75rem;
    text-align: center;
    border: none;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-modern thead th:first-child {
    border-radius: 0.5rem 0 0 0;
}

.table-modern thead th:last-child {
    border-radius: 0 0.5rem 0 0;
}

.table-modern tbody tr {
    transition: all 0.2s;
    background: white;
}

.table-modern tbody tr:nth-child(odd) {
    background: var(--gray-50);
}

.table-modern tbody tr:hover {
    background: #e0f2fe !important;
    transform: scale(1.002);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.table-modern tbody td {
    padding: 0.75rem;
    border: 1px solid var(--gray-200);
    vertical-align: middle;
}

.table-modern tbody td:first-child {
    text-align: center;
    font-weight: 700;
    color: var(--primary);
    font-size: 1rem;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.table-modern .form-control-sm {
    border: 1px solid var(--gray-300);
    background: white;
    transition: all 0.2s;
}

.table-modern .form-control-sm:focus {
    border-color: var(--primary);
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.table-modern textarea.form-control-sm {
    min-height: 70px;
    resize: vertical;
}

.table-modern input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    accent-color: var(--primary);
    transition: all 0.2s;
}

.table-modern input[type="checkbox"]:hover {
    transform: scale(1.1);
}

/* ===== Buttons ===== */
.btn {
    border: none;
    border-radius: 0.625rem;
    padding: 0.625rem 1.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #1e3a8a 100%);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary) 0%, #475569 100%);
}

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

.btn-outline-secondary:hover {
    background: var(--secondary);
    color: white;
}

.btn-sm {
    padding: 0.375rem 1rem;
    font-size: 0.8125rem;
}

.delete-row-btn {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
}

.btn-add-row {
    margin-top: 1rem;
}

/* ===== Alerts ===== */
.alert {
    border: none;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
    animation: slideIn 0.3s;
}

.alert-success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

.alert-danger {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
}

.alert-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

.alert-info {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    color: #075985;
}

/* ===== Badges ===== */
.badge {
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    font-size: 0.8125rem;
    border-radius: 0.5rem;
}

/* ===== Loading ===== */
.loading {
    display: flex;
    justify-content: center;
    padding: 3rem;
}

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

::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--secondary);
    border-radius: 5px;
}

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .card-body {
        padding: 1.25rem;
    }

    .mechanics-info {
        padding: 1.25rem;
    }

    .table-modern {
        font-size: 0.8125rem;
    }

    .table-modern thead th,
    .table-modern tbody td {
        padding: 0.5rem 0.375rem;
    }
}

/* ===== Print ===== */
@media print {
    body {
        background: white;
    }

    .navbar, .list-group, .btn, .alert {
        display: none;
    }

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

/* ===== Sidebar Toggle ===== */
#sidebar {
    transition: all 0.3s ease;
}

#sidebar.hidden {
    margin-left: -100%;
    display: none;
}

#mainContent {
    transition: all 0.3s ease;
}

#mainContent.expanded {
    flex: 0 0 100%;
    max-width: 100%;
}

#sidebarToggle {
    transition: all 0.3s ease;
}

#sidebarToggle:hover {
    transform: scale(1.1);
}

/* ===== Table Excel Style ===== */
.table-excel th {
    text-align: center !important;
    vertical-align: middle !important;
}

.table-excel thead th {
    /* background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); */
    color: rgb(0, 0, 0);
    font-weight: 600;
    text-align: center !important;
    vertical-align: middle !important;
    padding: 0.875rem 0.5rem;
    border: 1px solid rgba(7, 5, 5, 0.1);
    font-size: 0.8125rem;
}

/* ===== Table Controls ===== */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-radius: 0.75rem;
    border: 2px solid #93c5fd;
}

.table-controls h6 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-expand-table {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.btn-expand-table:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #1e3a8a 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-expand-table i {
    font-size: 1rem;
}

/* ===== Utilities ===== */
.hr-only {
    display: none;
}

/* ===== Stats Box (for Modal Summary) ===== */
.stats-box {
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 0.75rem;
    border: 2px solid var(--gray-200);
    transition: all 0.2s;
}

.stats-box:hover {
    background: white;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stats-box h4 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
}

.stats-box small {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-weight: 500;
}

/* ===== Modal Customization ===== */
.modal-xl {
    max-width: 95%;
}

.modal-content {
    border: none;
    border-radius: 1rem;
    box-shadow: var(--shadow-xl);
    animation: scaleIn 0.3s ease;
}

.modal-header {
    border-bottom: 2px solid var(--gray-200);
    padding: 1.5rem;
}

.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    border-top: 2px solid var(--gray-200);
    padding: 1rem 1.5rem;
}

/* ===== Confirmation Modal ===== */
#confirmModal .modal-content {
    animation: bounceIn 0.4s ease;
}

#confirmModal .modal-header {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    color: white;
}

#confirmModal .modal-header.danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
}

#confirmModal .modal-header.success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

#confirmModal .modal-header.info {
    background: linear-gradient(135deg, var(--info) 0%, #0891b2 100%);
}

#confirmModal .modal-body {
    font-size: 1.125rem;
    padding: 2rem;
    text-align: center;
}

#confirmModal .modal-title i {
    font-size: 1.5rem;
    animation: pulse 2s infinite;
}

/* ===== Page Content Animation ===== */
#pageContent {
    animation: fadeIn 0.5s ease;
}

#pageContent > * {
    animation: slideInUp 0.6s ease;
}

/* ===== Table Row Animation ===== */
.table-modern tbody tr {
    animation: slideInRight 0.3s ease;
}

.table-modern tbody tr:nth-child(1) { animation-delay: 0.05s; }
.table-modern tbody tr:nth-child(2) { animation-delay: 0.1s; }
.table-modern tbody tr:nth-child(3) { animation-delay: 0.15s; }
.table-modern tbody tr:nth-child(4) { animation-delay: 0.2s; }
.table-modern tbody tr:nth-child(5) { animation-delay: 0.25s; }

/* ===== Loading Spinner ===== */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.loading-overlay .spinner-container {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-xl);
    text-align: center;
    animation: scaleIn 0.3s ease;
}

.loading-overlay .spinner-container .loading-spinner {
    margin-bottom: 1rem;
}

/* ===== Button Animations ===== */
.btn-pulse {
    animation: pulse 1.5s infinite;
}

.btn-shake {
    animation: shake 0.5s;
}

/* ===== Success/Error Animation ===== */
.success-checkmark {
    display: inline-block;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--success);
    position: relative;
    animation: scaleIn 0.5s ease;
}

.success-checkmark::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 2rem;
    font-weight: bold;
}
