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

:root {
    --primary: #32c52d;
    --primary-light: #72fa60;
    --primary-dark: #23af1e;
    --success: #16bd00;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-dark: #0f0f0f;
    --bg-dark-2: #171717;
    --bg-dark-3: #1f1f1f;
    --bg-dark-4: #262626;
    --text-light: #f5f5f5;
    --text-muted: #a0a0a0;
    --border-dark: #333333;
    --font-thai: 'Anuphan', 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html[data-theme="light"] {
    --bg-dark: #f8f8f8;
    --bg-dark-2: #ffffff;
    --bg-dark-3: #f3f4f6;
    --bg-dark-4: #e5e7eb;
    --text-light: #111827;
    --text-muted: #71806b;
    --border-dark: #e5e7eb;
}

body {
    font-family: var(--font-thai);
    background-color: var(--bg-dark);
    color: var(--text-light);
    transition: background-color 0.3s, color 0.3s;
}

/* Apply Thai loopless font to all form controls too */
button, input, select, textarea {
    font-family: var(--font-thai);
}

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

/* Topbar */
.topbar {
    height: 47px;
    background-color: var(--bg-dark-2);
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.topbar-logo {
    width: 32px;
    height: 32px;
    background: transparent;
    border-radius: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 14px;
}

.topbar-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.breadcrumb-item {
    color: var(--text-light);
    font-weight: 500;
}

.breadcrumb-sep {
    color: var(--text-muted);
    opacity: 0.5;
}

.breadcrumb-link {
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
    padding: 2px 6px;
    border-radius: 3px;
}

.breadcrumb-link:hover {
    background: var(--bg-dark-3);
    color: var(--text-light);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.theme-toggle:hover {
    background: var(--bg-dark-3);
}

.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.user-menu:hover {
    background: var(--bg-dark-3);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    font-size: 12px;
}

.user-info {
    display: flex;
    flex-direction: column;
    font-size: 12px;
}

.user-name {
    font-weight: 600;
    color: var(--text-light);
}

.user-role {
    color: var(--text-muted);
    font-size: 11px;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-dark-2);
    border: 1px solid var(--border-dark);
    border-radius: 6px;
    min-width: 180px;
    margin-top: 8px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-light);
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-dark);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--bg-dark-3);
}

/* Layout */
.app-container {
    display: flex;
    height: calc(100vh - 47px);
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-dark-2);
    border-right: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
    transition: width 0.3s;
    overflow-y: auto;
    height: calc(100vh - 47px);
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .sidebar-label {
    display: none;
}

.sidebar.collapsed .report-chevron {
    display: none;
}

.sidebar.collapsed .sidebar-submenu {
    display: none;
}

.sidebar-menu {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar-menu::-webkit-scrollbar {
    display: none;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    border-left: 3px solid transparent;
}

.sidebar.collapsed .sidebar-item {
    justify-content: center;
    position: relative;
}

.sidebar.collapsed .sidebar-item[data-title]::after {
    content: attr(data-title);
    position: absolute;
    left: 64px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-dark-2);
    color: var(--text-light);
    border: 1px solid var(--border-dark);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
    transition: opacity 0.15s ease;
    z-index: 1500;
}

.sidebar.collapsed .sidebar-item[data-title]:hover::after {
    opacity: 1;
}

.sidebar-item:hover {
    background: var(--bg-dark-3);
    color: var(--text-light);
}

.sidebar-item.active {
    background: var(--bg-dark-3);
    color: var(--primary);
    border-left-color: var(--primary);
}

.sidebar-icon {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-label {
    white-space: nowrap;
}

.sidebar-submenu {
    display: none;
    padding: 0;
    border-left: 1px solid var(--border-dark);
    margin: 0;
}

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

.sidebar-subitem {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px 10px 40px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.sidebar-subitem:hover {
    color: var(--text-light);
    background: var(--bg-dark-3);
}

.sidebar-subitem.active {
    color: var(--primary);
}

.sidebar-collapse-btn {
    width: 100%;
    height: 44px;
    background: none;
    border: none;
    border-top: 1px solid var(--border-dark);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-top: auto;
    position: sticky;
    bottom: 0;
    background: var(--bg-dark-2);
}

.sidebar-collapse-btn:hover {
    background: var(--bg-dark-3);
    color: var(--text-light);
}

.collapsed-submenu {
    display: none;
    position: fixed;
    min-width: 190px;
    background: var(--bg-dark-2);
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
    z-index: 2000;
    padding: 6px 0;
}

.collapsed-submenu.show {
    display: block;
}

.collapsed-submenu .sidebar-subitem {
    padding: 10px 14px;
    margin: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-dark);
}

.content {
    padding: 12px;
    flex: 1;
}

/* Buttons */
.btn {
    background: #008d0c;
    color: white;
    border: 1px solid #00b70f;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--primary-light);
    box-shadow: 0 2px 8px rgba(59, 246, 68, 0.3);
}

.btn-secondary {
    background: var(--bg-dark-3);
    color: var(--text-light);
    border: 1px solid var(--border-dark);
}

.btn-secondary:hover {
    background: var(--bg-dark-4);
    border-color: var(--primary);
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-label {
        display: none;
    }
}
