:root {
    /* Primary Colors - Purple Theme */
    --primary: #7c3aed;
    --primary-light: #8b5cf6;
    --primary-dark: #6d28d9;
    --secondary: #ec4899;
    --secondary-light: #f472b6;
    --secondary-dark: #db2777;

    /* Background Colors - Light Theme */
    --bg-dark: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-hover: rgba(255, 255, 255, 1);
    --bg-glass: rgba(255, 255, 255, 0.95);

    /* Text Colors - Dark on Light */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Status Colors */
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.15);

    /* Booking Status Colors - Light Theme */
    --available: #f1f5f9;
    --available-bg: #ffffff;
    --booked: #ef4444;
    --booked-bg: rgba(239, 68, 68, 0.25);
    --past: #94a3b8;
    --past-bg: rgba(148, 163, 184, 0.3);
    --my-booking: #7c3aed;
    --my-booking-bg: rgba(124, 58, 237, 0.25);

    /* Shadows - Softer for light theme */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.2);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Additional Light Theme Colors */
    --border-color: rgba(0, 0, 0, 0.08);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans Thai', 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5em;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.75rem;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--secondary);
}

/* Container */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    position: sticky;
    box-shadow: var(--shadow-sm);
    top: 0;
    z-index: 1000;
    padding: 0.75rem 0;
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.navbar-brand .logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #374151, #4b5563);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    flex-wrap: wrap;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    font-size: 0.9rem;
}

.nav-link:hover,
.nav-link.active {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: linear-gradient(135deg, #374151, #4b5563);
    color: #ffffff;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    text-align: right;
    font-size: 0.85rem;
}

.user-info .name {
    color: var(--text-primary);
    font-weight: 500;
}

.user-info .role {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Header Credit Display */
.header-credit-display {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 1px solid #f59e0b;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    color: #92400e;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.header-credit-display:hover {
    background: linear-gradient(135deg, #fde68a, #fcd34d);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
    color: #78350f;
}

.header-credit-display i {
    color: #f59e0b;
}

@media (max-width: 768px) {
    .header-credit-display {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
}

/* Mobile Menu Toggle */
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

@media (max-width: 768px) {
    .navbar-toggle {
        display: block;
    }

    .navbar-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        padding: 1rem 0;
        gap: 0.25rem;
    }

    .navbar-nav.show {
        display: flex;
    }

    .nav-link {
        width: 100%;
        justify-content: flex-start;
    }
}

/* Cards */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.card:hover {
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: #000;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    color: var(--text-primary);
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.2);
}

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

select.form-control {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-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='%23a1a1aa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

select.form-control option {
    background-color: #ffffff;
    color: #1e293b;
    padding: 10px;
}

select.form-control option:hover,
select.form-control option:focus,
select.form-control option:checked {
    background-color: #7c3aed;
    color: #ffffff;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Input Groups */
.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group .form-control {
    flex: 1;
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid var(--success);
    color: var(--success);
}

.alert-danger {
    background: var(--danger-bg);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.alert-warning {
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    color: var(--warning);
}

.alert-info {
    background: var(--info-bg);
    border: 1px solid var(--info);
    color: var(--info);
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-primary {
    background: var(--primary);
    color: white;
}

.badge-success {
    background: var(--success);
    color: white;
}

.badge-danger {
    background: var(--danger);
    color: white;
}

.badge-warning {
    background: var(--warning);
    color: #000;
}

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

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: var(--bg-card-hover);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    padding: 1rem;
    overflow-y: auto;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: relative;
    background: linear-gradient(145deg, #ffffff, #f8fafc);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: all var(--transition-normal);
    margin: auto;
}

.modal>form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color var(--transition-fast);
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

/* Timetable Grid */
.timetable-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
}

.timetable {
    display: grid;
    min-width: 600px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #ffffff;
}

.timetable-header {
    display: contents;
}

.timetable-header .cell {
    background: linear-gradient(135deg, #374151, #4b5563);
    font-weight: 600;
    text-align: center;
    padding: 0.875rem 0.5rem;
    font-size: 0.9rem;
    position: sticky;
    top: 0;
    z-index: 10;
    color: #ffffff;
}

.timetable-row {
    display: contents;
}

.timetable .cell {
    padding: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.timetable .time-cell {
    background: var(--bg-card);
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 70px;
    position: sticky;
    left: 0;
    z-index: 5;
}

.timetable .slot {
    cursor: pointer;
    position: relative;
    min-width: 120px;
}

.timetable .slot:hover {
    background: var(--bg-card-hover);
}

/* Slot Status */
.slot.available {
    background: var(--available-bg);
}

.slot.available:hover {
    background: var(--available);
}

.slot.booked {
    background: var(--booked-bg);
    cursor: default;
}

.slot.my-booking {
    background: var(--my-booking-bg);
    cursor: pointer;
}

.slot.past {
    background: var(--past-bg);
    cursor: not-allowed;
    opacity: 0.6;
}

.slot.closed {
    background: repeating-linear-gradient(45deg,
            rgba(148, 163, 184, 0.2),
            rgba(148, 163, 184, 0.2) 5px,
            rgba(148, 163, 184, 0.3) 5px,
            rgba(148, 163, 184, 0.3) 10px);
    cursor: not-allowed;
    opacity: 0.5;
}

.slot.disabled {
    background: rgba(239, 68, 68, 0.2);
    cursor: not-allowed;
    position: relative;
    border-left: 3px solid #ef4444;
}

.slot.disabled::before {
    content: "ปิดใช้งานเตียง";
    font-size: 0.7rem;
    color: #dc2626;
    font-weight: 600;
}

.slot.disabled:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Status-based booking colors */
.slot.status-booked {
    background: rgba(234, 179, 8, 0.25);
    border-left: 3px solid #eab308;
}

.slot.status-arrived {
    background: rgba(59, 130, 246, 0.25);
    border-left: 3px solid #3b82f6;
}

.slot.status-shampoo {
    background: rgba(139, 92, 246, 0.25);
    border-left: 3px solid #8b5cf6;
}

.slot.status-blowdry {
    background: rgba(236, 72, 153, 0.25);
    border-left: 3px solid #ec4899;
}

.slot.status-completed {
    background: rgba(34, 197, 94, 0.25);
    border-left: 3px solid #22c55e;
}

.slot.status-cancelled {
    background: rgba(239, 68, 68, 0.15);
    border-left: 3px solid #ef4444;
    opacity: 0.5;
}

.slot-content {
    font-size: 0.75rem;
    text-align: center;
    padding: 0.25rem;
}

.slot-content .service {
    font-weight: 500;
    color: var(--text-primary);
}

.slot-content .customer {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* Available Slot Text */
.available-slot-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: #9ca3af;
    text-align: center;
    padding: 0.5rem;
    line-height: 1.2;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.slot.available:hover .available-slot-text {
    opacity: 1;
    color: #6b7280;
}

/* Mobile Bed Selector */
.mobile-bed-selector {
    display: none;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: var(--shadow-sm);
}

@media (max-width: 640px) {
    .mobile-bed-selector {
        display: block;
    }

    /* On mobile, hide all bed columns except the selected one */
    .timetable {
        grid-template-columns: 70px 1fr !important;
        min-width: auto;
    }

    .timetable .bed-col {
        display: none;
    }

    .timetable .bed-col.active {
        display: flex;
        justify-content: center;
        align-items: center;
        min-width: auto;
    }

    /* Hide header bed columns on mobile since we have selector */
    .timetable-header .bed-col {
        display: none;
    }

    .timetable-header .bed-col.active {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .timetable .slot {
        min-width: auto;
    }
}

/* Date Picker */
.date-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.date-picker input[type="date"] {
    padding: 0.5rem 1rem;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
}

.date-picker input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1.5rem 0;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
    box-shadow: var(--shadow-glow);
}

.auth-title {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

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

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

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

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

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

.stat-details {
    flex: 1;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-card);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

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

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

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

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

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

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.d-flex {
    display: flex;
}

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

.justify-content-between {
    justify-content: space-between;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.w-100 {
    width: 100%;
}

/* Responsive */
@media (max-width: 640px) {
    html {
        font-size: 14px;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

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

    .modal {
        max-width: 100%;
        margin: 0.5rem;
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

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