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

/* Maledpan Local Font Face (if installed or placed locally) */
@font-face {
    font-family: 'Maledpan';
    src: local('Maledpan'), local('Maledpan-Regular'),
         url('fonts/Maledpan.woff2') format('woff2'),
         url('fonts/Maledpan.woff') format('woff'),
         url('fonts/Maledpan.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Maledpan';
    src: local('Maledpan Bold'), local('Maledpan-Bold'),
         url('fonts/Maledpan-Bold.woff2') format('woff2'),
         url('fonts/Maledpan-Bold.woff') format('woff'),
         url('fonts/Maledpan-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --primary: #17C2D7; /* Cyan from the chart */
    --primary-hover: #139BAE;
    --primary-light: #e0f8fb;
    --bg-color: #F4F7F6;
    --surface: #FFFFFF;
    --surface-border: #E8ECEE;
    --text-primary: #334155;
    --text-secondary: #64748b;
    --danger: #ef4444;
    --success: #16a34a;
    --accent: #FF9B44; /* Orange accent from the image */
    --sidebar-width: 270px;
    --sidebar-collapsed-width: 78px;
    --font-stack: 'Maledpan', 'Prompt', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
    font-family: var(--font-stack);
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
    font-family: var(--font-stack);
}

.container {
    width: 100%;
    max-width: 480px;
    padding: 2rem;
    animation: fadeIn 0.3s ease-out;
    margin: 2rem auto;
}

.container-large {
    max-width: 1200px;
    margin: 2rem auto;
}

/* ===================================================
   Dashboard & Unified Sidebar Layout
   =================================================== */
.dashboard-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
}

/* Sidebar Top Branding (Centered as before) */
.sidebar-brand {
    position: relative;
    padding: 1.25rem 1rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-bottom: 1px solid var(--surface-border);
    min-height: 85px;
    background: #ffffff;
}

.brand-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: inherit;
    width: 100%;
}

.brand-logo-img {
    max-width: 100%;
    height: auto;
    max-height: 52px;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    object-fit: contain;
    transition: all 0.2s ease;
}

.brand-company-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--primary);
    line-height: 1.3;
    text-align: center;
    word-break: break-word;
    letter-spacing: -0.2px;
}

/* Toggle Button for collapsing navbar */
.sidebar-toggle-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #64748b;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    z-index: 5;
}

.sidebar-toggle-btn:hover {
    background: #e2e8f0;
    color: var(--primary);
    transform: scale(1.05);
}

/* Sidebar Profile Section */
.sidebar-profile {
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border-bottom: 1px solid var(--surface-border);
    background: #fafbfc;
    transition: all 0.2s ease;
}

.sidebar-profile-img {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, #0284c7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #ffffff;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(23, 194, 215, 0.25);
}

.sidebar-profile-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-profile-info .profile-greeting {
    font-size: 0.78rem;
    color: #94a3b8;
    display: block;
    line-height: 1.1;
}

.sidebar-profile-info strong {
    display: block;
    color: #1e293b;
    font-size: 0.98rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.profile-role-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 0.2rem;
    text-transform: uppercase;
}

.profile-role-badge.role-admin {
    background: #fef3c7;
    color: #b45309;
}
.profile-role-badge.role-hr {
    background: #fce7f3;
    color: #be185d;
}
.profile-role-badge.role-manager {
    background: #e0e7ff;
    color: #4338ca;
}
.profile-role-badge.role-employee {
    background: #e2e8f0;
    color: #475569;
}

/* Navigation Links */
.sidebar-nav {
    list-style: none;
    padding: 0.85rem 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav li {
    position: relative;
    margin-bottom: 2px;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1.25rem;
    color: #475569;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: background 0.18s, color 0.18s, border-left 0.18s;
    border-left: 4px solid transparent;
    white-space: nowrap;
}

.nav-icon {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease;
}

.sidebar-nav li a:hover {
    background: #f8fafc;
    color: var(--primary-hover);
}

.sidebar-nav li.active > a {
    color: #0369a1;
    font-weight: 700;
    border-left-color: var(--primary);
    background: #f0fdf4;
    background: linear-gradient(90deg, rgba(23, 194, 215, 0.12) 0%, rgba(23, 194, 215, 0.02) 100%);
}

.sidebar-nav li a.danger {
    color: var(--danger);
}
.sidebar-nav li a.danger:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.nav-item-disabled {
    opacity: 0.6;
    cursor: default;
}

.nav-logout-item {
    margin-top: 1rem;
    border-top: 1px dashed var(--surface-border);
    padding-top: 0.5rem;
}

/* Submenu dropdown inside sidebar */
.submenu-toggle-btn {
    cursor: pointer;
    user-select: none;
}

.submenu-arrow {
    font-size: 0.68rem;
    transition: transform 0.22s ease;
    color: #94a3b8;
    margin-left: auto;
}

.sidebar-submenu {
    list-style: none;
    padding: 0.25rem 0 0.5rem 2.85rem;
    background: #f8fafc;
    display: none; /* Hidden by default */
    border-left: 2px solid #e2e8f0;
    margin: 0 1rem 0 1.5rem;
    border-radius: 0 0 6px 6px;
}

.has-submenu.submenu-open .sidebar-submenu {
    display: block; /* Expand when opened */
}

.has-submenu.submenu-open .submenu-arrow {
    transform: rotate(180deg);
}

.sidebar-submenu li a {
    padding: 0.45rem 0.75rem;
    font-size: 0.88rem;
    color: #64748b;
    border-left: none;
    border-radius: 4px;
    gap: 0.5rem;
}

.sidebar-submenu li a:hover {
    color: var(--primary-hover);
    background: #f1f5f9;
}

.sidebar-submenu li.active a {
    color: var(--primary-hover);
    font-weight: 700;
    background: #e0f2fe;
}

.submenu-dot {
    font-size: 1.2rem;
    line-height: 0.8;
    color: #94a3b8;
}
.sidebar-submenu li.active .submenu-dot {
    color: var(--primary);
}

/* Top-Right Monolit System Branding Badge */
.top-right-monolit {
    position: fixed;
    top: 12px;
    right: 20px;
    z-index: 999;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 8px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    user-select: none;
    transition: all 0.2s ease;
}

.top-right-monolit:hover {
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.monolit-top-logo {
    height: 20px;
    width: auto;
    max-width: 26px;
    object-fit: contain;
    display: block;
}

.monolit-top-title {
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    color: #1e293b;
    line-height: 1;
}

.monolit-top-badge {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--primary);
    background: #e0f2fe;
    padding: 1px 6px;
    border-radius: 999px;
    letter-spacing: 0.4px;
}

/* ===================================================
   Collapsed Sidebar State (ย่อเมนูไปด้านข้าง)
   =================================================== */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .brand-company-name,
body.sidebar-collapsed .sidebar-profile-info,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .submenu-arrow,
body.sidebar-collapsed .sidebar-submenu {
    display: none !important;
}

body.sidebar-collapsed .sidebar-brand {
    padding: 0.75rem 0.25rem;
    min-height: auto;
    justify-content: center;
}

body.sidebar-collapsed .brand-link {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
}

body.sidebar-collapsed .brand-logo-img {
    max-height: 28px;
    margin-bottom: 0.25rem;
}

body.sidebar-collapsed .sidebar-toggle-btn {
    position: static;
    margin: 0 auto;
    width: 26px;
    height: 26px;
}

body.sidebar-collapsed .sidebar-profile {
    justify-content: center;
    padding: 1rem 0.5rem;
}

body.sidebar-collapsed .sidebar-nav li a {
    justify-content: center;
    padding: 0.85rem 0.5rem;
    border-left: none;
}

body.sidebar-collapsed .sidebar-nav li.active a {
    background: var(--primary-light);
    color: var(--primary-hover);
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 2rem 2.25rem;
    background: var(--bg-color);
    min-width: 0; /* Prevent flex blowout */
    transition: all 0.28s ease;
}

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.placeholder-card {
    background: #ffffff;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 1rem;
    min-height: 150px;
    margin-bottom: 1.5rem;
}

/* Data Table Styles */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--surface-border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--surface-border);
}

.data-table th {
    background-color: var(--bg-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.data-table td {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.data-table tr:hover {
    background-color: #f9fafb;
}

.badge {
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge.primary { background: #e0f2fe; color: #0284c7; }
.badge.success { background: #dcfce7; color: #166534; }
.badge.warning { background: #fef9c3; color: #854d0e; }

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

h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: left;
    color: var(--text-primary);
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 1.25rem 0;
    color: var(--text-primary);
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 0.75rem;
}

p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
    text-align: center;
}

.alert {
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 500;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #FCA5A5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #6EE7B7;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.form-group {
    margin-bottom: 1.5rem;
}

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

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="number"],
select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: #ffffff;
    border: 1px solid var(--surface-border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--primary);
}

/* Fix missing background on navigation links for light mode */
.nav-links a {
    display: block;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    color: var(--text-primary);
    text-decoration: none;
    text-align: center;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-links a:hover {
    background: #ffffff;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

button {
    width: auto;
    min-width: 150px;
    padding: 0.6rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

button:hover {
    background: var(--primary-hover);
}

button:active {
    transform: translateY(0);
}

.nav-links {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.nav-links li {
    display: block;
}

.nav-links a {
    display: block;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    color: var(--text-primary);
    text-decoration: none;
    text-align: center;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-links a:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.nav-links a.danger {
    color: #FCA5A5;
    border-color: rgba(239, 68, 68, 0.3);
}

.nav-links a.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #EF4444;
}

.back-link {
    display: inline-block;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.3s ease;
    text-align: center;
    width: 100%;
}

.back-link:hover {
    color: var(--text-primary);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.section-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 6px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.radio-group {
    display: flex;
    gap: 1rem;
    align-items: center;
    height: 100%;
    padding-top: 0.5rem;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

input[type="radio"] {
    accent-color: var(--primary);
    width: 1.2rem;
    height: 1.2rem;
}

@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    .container {
        padding: 2rem;
        margin: 1rem;
        width: calc(100% - 2rem);
    }
}

@media (max-width: 640px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    .container {
        padding: 1.5rem;
    }
    h2 {
        font-size: 1.5rem;
    }
}
