:root {
    /* Theme Colors: Warm Yellow / Light Orange */
    --primary-color: #FFA726;
    /* Orange 400 */
    --primary-light: #FFCC80;
    /* Orange 200 */
    --primary-dark: #F57C00;
    /* Orange 700 */

    --secondary-color: #FFECB3;
    /* Amber 100 */
    --accent-color: #FF7043;
    /* Deep Orange 400 */

    --bg-color: #FFF8E1;
    /* Main background - very light amber */
    --sidebar-bg: #FFFFFF;
    --card-bg: #FFFFFF;

    --text-main: #4E342E;
    /* Dark Brown for text instead of harsh black */
    --text-secondary: #8D6E63;

    --border-color: #FFE0B2;

    /* Spacing */
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;

    /* Border Radius */
    --radius-md: 8px;
    --radius-lg: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', "Microsoft JhengHei", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* Layout */
#app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: var(--spacing-md);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
}

.logo {
    margin-bottom: var(--spacing-lg);
    text-align: center;
}

.logo h2 {
    color: var(--primary-dark);
}

.user-info {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-top: var(--spacing-sm);
}

#nav-links {
    list-style: none;
}

#nav-links li {
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s;
    color: var(--text-main);
    font-weight: 500;
}

#nav-links li:hover {
    background-color: var(--secondary-color);
}

#nav-links li.active {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: 60px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--spacing-lg);
}

#content-area {
    flex: 1;
    padding: var(--spacing-lg);
    overflow-y: auto;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--primary-dark);
    color: var(--primary-dark);
}

.btn-secondary:hover {
    background-color: var(--secondary-color);
}

/* Forms */
.form-group {
    margin-bottom: var(--spacing-md);
}

label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: bold;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: #FFF;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    border-color: transparent;
}

/* Cards & Tables */
.card {
    background-color: var(--card-bg);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: var(--spacing-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--spacing-md);
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--secondary-color);
    color: var(--primary-dark);
}

/* Utilities */
.hidden {
    display: none !important;
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- RWD / Responsive Styles --- */

/* Mobile First Adjustments */

/* Utilities */
.mobile-only {
    display: block;
}

.desktop-only {
    display: none;
}

@media (min-width: 768px) {
    .mobile-only {
        display: none !important;
    }

    .desktop-only {
        display: block;
    }
}

/* Responsive Sidebar (for Admin) */
@media (max-width: 768px) {
    #app {
        flex-direction: column;
        /* Stack top-down or keep layout but handle sidebar */
        position: relative;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        /* Hidden off-screen */
        height: 100vh;
        z-index: 2000;
        /* Increased z-index */
        transition: left 0.3s ease;
        width: 250px;
        background-color: #FFF;
        /* Ensure background */
        overflow-y: auto;
        /* Allow scrolling inside sidebar */
        display: block;
        /* Ensure it's not flex-hidden */
        box-shadow: none;
    }

    .sidebar.active {
        left: 0;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.2);
        display: flex;
        /* Restore flex layout for internal items */
        flex-direction: column;
    }

    .main-content {
        width: 100%;
        flex: 1;
        /* Ensure it takes available space */
        min-width: 0;
        /* Fix flex overflow issues */
    }

    /* Overlay background when sidebar is open */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Hamburger in Top Bar */
    .menu-toggle {
        display: block;
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0 15px;
        background: none;
        border: none;
        color: var(--primary-dark);
    }
}

@media (min-width: 769px) {
    .menu-toggle {
        display: none;
        /* Hide on desktop */
    }
}

/* Make tables responsive */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}