:root {
    /* Design Language Palette */
    --primary-color: #1a1f3d;
    /* primary */
    --sidebar-bg: #1a1f3d;
    --primary-light: #2a3150;
    --primary-dark: #0f1222;
    --accent-color: #f4b940;
    /* accent */
    --accent-dark: #e5a51c;
    --background-color: #f8f9fb;
    /* surface */
    --card-bg: #fff;
    /* background */
    --border-color: #e5e7eb;
    --text-dark: #1f2937;
    /* text-primary */
    --text-muted: #6b7280;
    /* text-secondary */
    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    /* Spacing & Radius */
    --radius: 0.625rem;
    /* 10px */
    --p-card: 1.5rem;
    /* 24px */
    /* Typography */
    --font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    /* Light background colors for card icons (derived from status colors) */
    --bg-blue-light: #dbeafe;
    /* Lighter version of info */
    --bg-green-light: #d1fae5;
    /* Lighter version of success */
    --bg-red-light: #fee2e2;
    /* Lighter version of error */
    --bg-yellow-light: #fef3c7;
    /* Lighter version of warning */
    --bg-purple-light: #f3e8ff;
    /* Custom light purple */
    --bg-teal-light: #ccfbf1;
    /* Custom light teal */
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dark);
    min-height: 100vh;
}

/* Dashboard Layout */
.dashboard-container {
    display: grid;
    grid-template-columns: auto 1fr; /* Allow sidebar to control its own width */
    width: 100vw;
    height: 100vh;
    background-color: var(--sidebar-bg);
}

/* Sidebar */
/* ===========================
   SIDEBAR BASE STYLES
=========================== */
.sidebar {
    width: 88px; /* Collapsed width */
    overflow: hidden;
    background-color: var(--sidebar-bg);
    color: #fff;
    padding: 1.5625rem 1.25rem; /* 25px 20px */
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    height: 100vh;
}

/* ===========================
   HEADER
=========================== */
.sidebar-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0 0.625rem;
    gap: 0.9375rem; /* 15px */
}

.sidebar-logo {
    width: 45px;
    height: auto;
    flex-shrink: 0;
}

.site-name {
    white-space: nowrap;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    transition: opacity 0.2s ease-in-out, max-width 0.3s ease-in-out;
    opacity: 0;
    max-width: 0;
    overflow: hidden;
}

.site-subname {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent-color);
    letter-spacing: 0.0625rem;
}

/* ===========================
   DIVIDERS
=========================== */
.sidebar-divider {
    border: none;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.1);
    margin: 1rem -1.25rem;
    width: calc(100% + 2 * 1.25rem);
}

/* ===========================
   NAVIGATION & FOOTER
=========================== */
.sidebar-nav {
    flex-grow: 1;
}

.sidebar-nav ul,
.sidebar-footer ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem; /* 8px */
}

/* LINKS (Collapsed State Default) */
.sidebar-nav li a,
.sidebar-footer li a {
    display: flex;
    align-items: center;
    justify-content: center; /* Center icons when collapsed */
    color: #fff;
    text-decoration: none;
    padding: 0.875rem;
    border-radius: var(--radius);
    font-weight: 400;
    transition:
        padding 0.3s ease,
        background-color 0.3s ease,
        gap 0.3s ease,
        justify-content 0.3s ease;
    white-space: nowrap;
    gap: 0;
}

/* Icon size & alignment */
.sidebar-nav li a i,
.sidebar-footer li a i {
    width: 1.75rem;  /* Larger when collapsed */
    height: 1.75rem;
    flex-shrink: 0;
}

/* Text (hidden initially) */
.sidebar-nav a span,
.sidebar-footer a span {
    transition: opacity 0.2s ease-in-out, max-width 0.3s ease-in-out;
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    display: inline-block;
}

/* Active Link */
.sidebar-nav li a.active {
    background-color: var(--accent-color);
    color: var(--primary-color);
    font-weight: 500;
}

.sidebar-footer li a.active {
    background-color: transparent; /* Logout link */
}

/* Hover Effects */
.sidebar-nav li a:hover,
.sidebar-footer li a:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #fff;
}

/* ===========================
   EXPANDED STATE (ON HOVER)
=========================== */
.sidebar.sidebar-expanded {
    width: 260px; /* Expanded width */
}

.sidebar.sidebar-expanded .site-name,
.sidebar.sidebar-expanded .sidebar-nav a span,
.sidebar.sidebar-expanded .sidebar-footer a span {
    opacity: 1;
    max-width: 200px;
    transition-delay: 0.1s;
}

.sidebar.sidebar-expanded .sidebar-nav li a,
.sidebar.sidebar-expanded .sidebar-footer li a {
    justify-content: flex-start; /* Align icon + text */
    padding: 0.875rem 1.25rem;
    gap: 0.75rem;
}

/* Restore icon size for expanded view */
.sidebar.sidebar-expanded .sidebar-nav li a i,
.sidebar.sidebar-expanded .sidebar-footer li a i {
    width: 1.5rem;
    height: 1.5rem;
}

.sidebar-toggle-icon {
    transition: transform 0.3s ease;
}
/* ===========================
   FOOTER
=========================== */
.sidebar-footer {
    margin-top: auto;
}


/* Main Content */
.main-content {
    background-color: var(--background-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: margin-left 0.3s ease;
    position: relative;
    /* Prevent double scrollbars */
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2.5rem;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    /* Prevent the bar from shrinking */
    gap: 1.5rem;
}

.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 450px;
}

.search-wrapper .search-icon-wrapper {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem; /* Same as input left padding */
    height: 100%;
}

.search-wrapper input {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 3rem;
    /* 10px 16px 10px 48px */
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background-color: var(--background-color);
    font-family: var(--font-family);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    color: var(--text-color);
}

.search-wrapper input::placeholder {
    color: var(--text-muted);
}

.search-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(26, 31, 61, 0.1);
}

.top-bar-right.user-actions {
    display: flex;
    align-items: center;
    gap: 2rem;
    /* Further increased spacing */
}

.action-btn {
    color: var(--text-muted);
    width: 2.5rem; /* 40px, same as avatar */
    height: 2.5rem; /* 40px, same as avatar */
    border-radius: var(--radius);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    text-decoration: none;
}

.notification-btn {
    position: relative;
}

.action-btn:hover {
    background-color: var(--primary-color);
    color: var(--text-dark);
    color: #fff;
}

.notification-count {
    position: absolute;
    top: -0.375rem; /* -6px */
    right: -0.375rem; /* -6px */
    background-color: var(--error);
    color: #fff;
    border-radius: 50%;
    font-size: 0.625rem;
    font-weight: 600;
    min-width: 1.125rem;
    height: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--background-color);
}

.profile-avatar img {
    width: 2.5rem;
    /* 40px */
    height: 2.5rem;
    /* 40px */
    border-radius: 50%;
    object-fit: cover;
}

.dashboard-scroll-area {
    padding: 2.5rem;
    overflow-y: auto;
    /* This area will scroll */
    flex-grow: 1;
}

.main-header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.main-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Page Footer */
.main-footer {
    /* The footer is now inside the scroll area */
    margin-top: 2.5rem; /* Space above the footer */
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color); /* Keep the top border */
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
}
.main-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

/* KPI Cards */
.kpi-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
}

.card {
    background: var(--card-bg);
    padding: var(--p-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 120px;
}

.card-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card-icon-wrapper {
    width: 3rem;
    /* 48px */
    height: 3rem;
    /* 48px */
    border-radius: var(--radius);
    /* Changed from 50% to var(--radius) */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 1rem;
    /* 16px */
}

.card-icon-wrapper i {
    width: 1.25rem;
    /* 20px */
    height: 1.25rem;
    /* 20px */
}

/* Icon Background Colors */
.bg-blue {
    background-color: var(--bg-blue-light);
    color: var(--info);
}

.bg-green {
    background-color: var(--bg-green-light);
    color: var(--success);
}

.bg-red {
    background-color: var(--bg-red-light);
    color: var(--error);
}

.bg-purple {
    background-color: var(--bg-purple-light);
    color: #7e22ce;
}

.bg-yellow {
    background-color: var(--bg-yellow-light);
    color: var(--warning);
}

.bg-teal {
    background-color: var(--bg-teal-light);
    color: #0d9488;
}

.card-content {
    flex-grow: 1;
}

.card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0;
}

.card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0;
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-top: auto;
    /* Pushes KPI value to the bottom */
}

/* New Tab Section */
.tab-section {
    margin-top: 2.5rem;
    /* These styles make the section a card */
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    overflow: hidden; /* To contain the border-radius */
}

.tab-bar-container {
    padding: 1rem 1.5rem 0 1.5rem; /* Padding around the tab bar */
}

.tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    gap: 0.5rem;
}

.tab-button {
    background-color: transparent;
    border: none;
    padding: 0.5rem 1rem; /* Reduced padding for a tighter look */
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease, border-bottom-color 0.2s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px; /* To make the active border sit on top of the main border */
}

.tab-button:hover {
    color: var(--primary-color);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.tab-content {
    display: none;
    /* background, border, and radius are now on .tab-section */
    padding: 1.5rem;
}

.tab-content-wrapper { }

.tab-content.active {
    display: block;
}

/* TODO Table Styles (similar to Recent Activity) */
.todo-table {
    display: table;
    width: 100%;
}

.todo-row {
    display: table-row;
}

.todo-row.header {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.todo-cell {
    display: table-cell;
    padding: 0.9375rem 0.625rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.todo-row:last-child .todo-cell {
    border-bottom: none;
}

/* DIY Configuration Cards */
.diy-config-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Responsive grid */
    gap: 1.5rem;
}

.diy-config-card {
    min-height: unset; /* Override min-height from general card style */
    align-items: flex-start; /* Align content to top */
    padding: 1.25rem; /* Slightly less padding than KPI cards */
    flex-direction: column; /* Stack content vertically */
    text-align: left;
}

.diy-config-card .card-content {
    margin-bottom: 1rem; /* Space between text and icon */
    width: 100%;
}

.diy-config-card h3 {
    font-size: 1.1rem; /* Slightly larger title */
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.diy-config-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.diy-config-card .card-icon-wrapper {
    margin-left: 0; /* Remove left margin */
    margin-top: auto; /* Push icon to bottom right */
    align-self: flex-end; /* Align icon to bottom right */
    width: 2.5rem; /* Smaller icon wrapper */
    height: 2.5rem;
}

.diy-config-card .card-icon-wrapper i {
    width: 1rem; /* Smaller icon */
    height: 1rem;
}

/* Recent Activity */
.recent-activity {
    margin-top: 2.5rem;
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.recent-activity h2 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    /* 20px */
}

.activity-table {
    display: table;
    width: 100%;
}

.activity-row {
    display: table-row;
}

.activity-row.header {
    font-weight: 600;
    font-weight: 500;
    /* Lighter font weight */
    color: var(--text-muted);
    font-size: 0.9rem;
}

.activity-cell {
    display: table-cell;
    /* Keep as table-cell for table layout */
    padding: 0.9375rem 0.625rem;
    /* 15px 10px */
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.activity-row:last-child .activity-cell {
    border-bottom: none;
}

.status-dot {
    height: 0.625rem;
    /* 10px */
    width: 0.625rem;
    /* 10px */
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
    /* 8px */
}

.status-dot.green {
    background-color: var(--success);
}

.status-dot.yellow {
    background-color: var(--warning);
}

.status-dot.red {
    background-color: var(--error);
}

/* Placeholder for "Coming Soon" pages */
.placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
}

.placeholder-content i {
    width: 3.75rem;
    /* 60px */
    height: 3.75rem;
    /* 60px */
    margin-bottom: 1.25rem;
    /* 20px */
    color: var(--primary-color);
}

.placeholder-content h1 {
    font-size: 1.875rem;
    /* h2 size */
    color: var(--text-dark);
}

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

@media (max-width: 992px) {
    .dashboard-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        /* In a real app, you'd hide this and show it with a burger menu */
        display: none;
    }

    .main-content {
        border-radius: 0;
    }

    .kpi-cards {
        grid-template-columns: 1fr;
    }
}

/* Media queries for new tab section responsiveness */
@media (max-width: 768px) {
    .tab-bar-container {
        padding: 1rem 1rem 0 1rem;
    }

    .tab-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    .tab-button {
        width: 100%;
        text-align: left;
        border-bottom: none;
        border-left: 2px solid transparent;
        margin-bottom: 0;
        padding: 0.75rem 1rem;
    }
    .tab-button.active {
        border-left-color: var(--primary-color);
        border-bottom-color: transparent;
    }
    .diy-config-cards {
        grid-template-columns: 1fr;
    }
}

/* --- Alert & Error Styles --- */
.alert {
  padding: 1rem;
  margin-bottom: 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.9rem;
  text-align: left;
}

.alert-danger {
  color: #721c24;
  background-color: #f8d7da;
  border-color: #f5c6cb;
}

.alert ul {
  list-style-position: inside;
  padding-left: 0;
}

/* --- Login Page Styles --- */
.login-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100vw;
    height: 100vh;
    background-color: var(--background-color);
}

.login-form-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    padding: 2.5rem 3.125rem;
    /* 40px 50px */
    /* Kept padding, increased max-width */
    border-radius: var(--radius);
    max-width: 480px;
    /* Increased login card size */
    width: 100%;
    text-align: center;
    border: 1px solid var(--border-color);
}

.login-logo img {
    width: 3.75rem;
    /* 60px */
    height: auto;
    /* Maintain aspect ratio */
    margin-bottom: 0.9375rem;
    /* 15px */
}

.product-title {
    font-size: 1.875rem;
    /* Aligned with h2 */
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.375rem;
    /* 6px */
}

.subtitle {
    font-size: 1rem;
    /* Aligned with p */
    color: var(--text-muted);
    margin-bottom: 1.875rem;
    /* 30px */
}

.form-group {
    text-align: left;
    margin-bottom: 1.25rem;
    /* 20px */
}

.form-group label {
    display: block;
    font-weight: 500;
    /* Lighter font weight */
    font-size: 0.875rem;
    /* text-sm */
    margin-bottom: 0.5rem;
    /* 8px */
    color: var(--text-dark);
}

.form-group input {
    width: 100%;
    padding: 0.75rem 0.875rem;
    /* 12px 14px */
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--background-color);
    font-size: 1rem;
    /* Aligned with p */
    transition: all 0.2s ease;
    font-family: var(--font-family);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(26, 31, 61, 0.1);
    /* Custom focus shadow */
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem; /* 24px */
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem; /* 8px */
}

.checkbox-group input[type="checkbox"] {
    width: 1rem; /* 16px */
    height: 1rem; /* 16px */
    border-radius: 0.25rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.checkbox-group input[type="checkbox"]:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-group label {
    font-size: 0.875rem; /* text-sm */
    color: var(--text-muted);
    cursor: pointer;
}

.form-group input.input-error {
    border-color: var(--error);
}

.form-group input.input-error:focus {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.field-error {
    color: var(--error);
    font-size: 0.875rem; /* text-sm */
    margin-top: 0.5rem; /* 8px */
    display: flex;
    align-items: center;
    gap: 0.375rem; /* 6px */
    font-weight: 500;
}

.error-icon {
    width: 1rem; /* 16px */
    height: 1rem; /* 16px */
    flex-shrink: 0;
    /* Prevents the icon from shrinking */
}

.btn-login {
    width: 100%;
    padding: 0.875rem;
    /* 14px */
    background-color: var(--primary-color);
    color: #fff;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-login:hover {
    background-color: var(--primary-dark);
}

.forgot-password {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.875rem;
    /* text-sm */
    transition: color 0.2s ease;
}

.forgot-password:hover {
    text-decoration: underline;
}

.login-image-wrapper {
    height: 100vh;
    overflow: hidden;
}

.login-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 900px) {
    .login-container {
        grid-template-columns: 1fr;
    }

    .login-image-wrapper {
        display: none;
    }
}

/* --- Content Card & Data Table Styles --- */
.content-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-top: 2.5rem;
}

.content-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.content-card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.header-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-weight: 500;
    border-radius: var(--radius);
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.header-actions .btn-primary {
    background-color: var(--primary-color);
    color: #fff;
    border: 1px solid var(--primary-color);
}

.header-actions .btn-secondary:hover {
    background-color: var(--background-color);
}

.header-actions .btn-primary:hover {
    background-color: var(--primary-dark);
}

.header-actions .btn i {
    width: 1rem;
    height: 1rem;
}

.table-responsive {
    overflow-x: auto;
}

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

.data-table th,
.data-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table thead th {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table thead th a.sortable-header {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s ease;
}

.data-table thead th a.sortable-header:hover {
    color: var(--text-dark);
}

.sort-indicator {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-arrow-up-down'%3E%3Cpath d='m21 16-4 4-4-4'%3E%3C/path%3E%3Cpath d='M17 20V4'%3E%3C/path%3E%3Cpath d='m3 8 4-4 4 4'%3E%3C/path%3E%3Cpath d='M7 4v16'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.5;
}

.data-table thead th a.sortable-header.asc .sort-indicator {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-arrow-up'%3E%3Cpath d='M12 19V5'%3E%3C/path%3E%3Cpath d='M5 12l7-7 7 7'%3E%3C/path%3E%3C/svg%3E");
    opacity: 1;
}

.data-table thead th a.sortable-header.desc .sort-indicator {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-arrow-down'%3E%3Cpath d='M12 5v14'%3E%3C/path%3E%3Cpath d='m19 12-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    opacity: 1;
}

/* Change color of active sort header text and icon */
.data-table thead th a.sortable-header.asc,
.data-table thead th a.sortable-header.desc {
    color: var(--text-dark);
}
.data-table thead th a.sortable-header.asc .sort-indicator,
.data-table thead th a.sortable-header.desc .sort-indicator {
    stroke: var(--text-dark); /* This won't work for the embedded SVG, but is good practice */
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.employee-cell {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.table-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.employee-info {
    display: flex;
    flex-direction: column;
}

.employee-name {
    font-weight: 500;
    color: var(--text-dark);
}

.employee-email {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-active { background-color: var(--bg-green-light); color: var(--success); }
.status-on.leave { background-color: var(--bg-yellow-light); color: var(--warning); }
.status-inactive { background-color: var(--bg-red-light); color: var(--error); }

.action-buttons {
    display: flex;
    gap: 0.75rem;
}

.action-btn-icon {
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.action-btn-icon:hover {
    color: var(--primary-color);
}

.table-checkbox-cell {
    width: 1%;
    padding-right: 0;
    padding-left: 1.5rem;
    text-align: center;
}

/* --- Pagination Styles --- */
.pagination-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.875rem;
    flex-wrap: wrap;
    color: var(--text-muted);
}

.records-per-page {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.records-per-page select {
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    font-family: var(--font-family);
    font-size: 0.875rem;
}

.records-per-page select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 31, 61, 0.1);
}

.pagination-nav {
  /* margin-left: auto; */ /* No longer needed with space-between */
}

.jump-to-page form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.jump-to-page label {
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.jump-to-page input {
  width: 70px;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  text-align: center;
}

.pagination {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 0.25rem; /* Reduced gap between buttons */
}

.pagination-item .pagination-link {
    display: block;
    padding: 0.4rem 0.8rem; /* Reduced padding for a more compact look */
    text-decoration: none;
    color: var(--text-muted);
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: all 0.2s ease;
    font-weight: 500;
}

.pagination-item:not(.disabled) .pagination-link:hover {
    background-color: var(--background-color);
    color: var(--primary-color);
}

.pagination-item.active .pagination-link {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    cursor: default;
}

.pagination-item.disabled .pagination-link {
    color: #ccc;
    background-color: var(--background-color);
    cursor: not-allowed;
    border-color: #eee;
}

@media (max-width: 992px) {
    .table-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
  }
  .pagination-container {
    justify-content: center;
    gap: 1.5rem;
    }
}

/* --- Table Controls (Search & Filter) --- */
.table-controls {
    display: flex;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.search-wrapper.local-search {
    width: 100%;
    max-width: 400px;
}

.search-wrapper.local-search input {
    background-color: #fff;
}

/* --- HTMX Loading Indicator --- */
#loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-color);
    opacity: 0;
    transition: opacity 300ms ease-out;
    z-index: 9999;
}

.htmx-request #loading-bar {
    opacity: 1;
}

.htmx-request #loading-bar::before {
    content: "";
    display: block;
    position: absolute;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, transparent, var(--primary-color), transparent);
    animation: htmx-loading-animation 1.5s linear infinite;
}

@keyframes htmx-loading-animation {
    from { left: -100%; }
    to   { left: 100%; }
}

/* --- Full Page Loader --- */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

#page-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* --- Content Area Loader --- */
#content-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease-in;
}

#content-loader.htmx-request {
    opacity: 1;
    pointer-events: all;
}

#content-loader .spinner {
    width: 40px;
    height: 40px;
}
