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

:root {
    --primary: #F97316; /* Orange 500 */
    --primary-hover: #EA580C; /* Orange 600 */
    --secondary: #64748B;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --background: #FFF7ED; /* Orange 50 */
    --surface: #FFFFFF;
    --text: #1F2937;
    --text-muted: #6B7280;
    --border: #FED7AA; /* Orange 200 */
    --radius: 0.5rem;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Sarabun', sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.auth-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #FB923C 0%, #F97316 100%);
    padding: 2rem 1rem 1.25rem 1rem;
}

.auth-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.auth-footer {
    margin-top: auto;
    text-align: center;
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.85rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    padding-top: 1rem;
}

.auth-footer a {
    color: white;
    text-decoration: underline;
}


.auth-card {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-logo {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #111827;
}

.auth-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.875rem;
}

.form-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: #374151;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.95rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.2);
}

.alert {
    padding: 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-danger {
    background-color: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

/* Dashboard Layout */
.layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.sidebar {
    width: 260px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    max-height: 100vh;
    z-index: 50;
    transition: transform 0.3s ease;
    overflow: hidden;
    box-sizing: border-box;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.app-logo {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.app-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: #111827;
}

.nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.nav::-webkit-scrollbar {
    width: 5px;
}
.nav::-webkit-scrollbar-track {
    background: transparent;
}
.nav::-webkit-scrollbar-thumb {
    background: #FED7AA;
    border-radius: 9999px;
}
.nav::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.sidebar-footer {
    padding: 0.75rem 0.75rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.logout-link {
    color: var(--danger, #DC2626) !important;
    font-weight: 600;
    transition: all 0.2s ease;
}

.logout-link:hover {
    background-color: #FEF2F2 !important;
    color: #B91C1C !important;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover, .nav-item.active {
    background-color: #FFEDD5; /* Orange-100 */
    color: var(--primary);
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    max-width: calc(100% - 260px);
    box-sizing: border-box;
}

.app-footer {
    margin-top: auto;
}


.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #111827;
}

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

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

.user-name {
    font-weight: 500;
    color: #111827;
    display: block;
}

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

.card {
    background: var(--surface);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    .main-content {
        margin-left: 240px;
        max-width: calc(100% - 240px);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
        box-shadow: 10px 0 15px -3px rgba(0, 0, 0, 0.1);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: 1rem;
        padding-top: 5rem;
    }

    .topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: var(--surface);
        padding: 1rem;
        z-index: 40;
        border-bottom: 1px solid var(--border);
        margin-bottom: 0;
    }

    .page-title {
        font-size: 1.1rem;
        margin-left: 3rem; /* Space for toggle button if positioned top-left */
    }

    .user-info {
        display: none; /* Hide name on very small screens to save space */
    }

    /* Table Responsive */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .card {
        padding: 1rem;
        border-radius: 0.75rem;
    }

    /* Grid adjustments */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Sidebar Backdrop for Mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 45;
    backdrop-filter: blur(2px);
}

.sidebar-backdrop.show {
    display: block;
}

/* Custom Scrollbar for Table Responsive */
.table-responsive::-webkit-scrollbar {
    height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #999;
}
