/**
 * Kayana Dreamland
 * Main Stylesheet
 * Modern Construction Project Management UI
 */

/* ============================================
   CSS VARIABLES & DESIGN TOKENS
   ============================================ */
:root {
    /* Primary Colors - Construction Blue */
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;

    /* Secondary Colors - Warm Amber */
    --secondary-50: #fffbeb;
    --secondary-100: #fef3c7;
    --secondary-200: #fde68a;
    --secondary-300: #fcd34d;
    --secondary-400: #fbbf24;
    --secondary-500: #f59e0b;
    --secondary-600: #d97706;

    /* Neutral Colors */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Status Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Layout */
    --sidebar-width: 280px;
    --sidebar-collapsed: 80px;
    --navbar-height: 64px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    width: 100%;
}

/* Base Responsive Container */
.kd-app-container,
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

a {
    color: var(--primary-600);
    text-decoration: none;
    transition: color var(--transition-fast);
}

input,
textarea,
[contenteditable="true"] {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

a:hover {
    color: var(--primary-700);
}

/* Global Icon Styling (Lucide Fix) - FORCE VISIBILITY */
[data-lucide],
.lucide,
svg[data-lucide],
.lucide-icon {
    width: 24px !important;
    height: 24px !important;
    stroke: currentColor !important;
    stroke-width: 2px !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    fill: none !important;
    display: inline-flex !important;
    vertical-align: middle !important;
    flex-shrink: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Sidebar Specific Icon Size */
.kd-sidebar-main [data-lucide],
.kd-sidebar-main svg {
    width: 20px !important;
    height: 20px !important;
}

/* Stat Card Icon Size */
.kd-stat-card [data-lucide],
.kd-stat-card svg {
    width: 28px !important;
    height: 28px !important;
}

svg {
    max-width: 100%;
    height: auto;
    display: block;
}

img,
canvas,
video {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

h4 {
    font-size: 1.125rem;
}

h5 {
    font-size: 1rem;
}

h6 {
    font-size: 0.875rem;
}

p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.text-lg {
    font-size: 1.125rem;
}

.text-muted {
    color: var(--text-muted);
}

.text-primary {
    color: var(--primary-600);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--danger);
}

/* ============================================
   LAYOUT - LOGIN PAGE
   ============================================ */
body.login-page {
    height: 100vh;
    overflow: hidden;
}

.login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    padding-bottom: 8vh;
    /* Slightly shift upwards for better visual balance */
    background: linear-gradient(135deg, var(--primary-900) 0%, var(--primary-700) 50%, var(--primary-600) 100%);
    position: relative;
    overflow: hidden;
}

@media (max-width: 768px) {
    .login-container {
        align-items: flex-start;
        padding-top: 10vh;
        padding-bottom: 0;
    }
}

.login-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect fill="none" stroke="rgba(255,255,255,0.05)" stroke-width="0.5" width="100" height="100"/></svg>') repeat;
    background-size: 50px 50px;
    animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(50px, 50px);
    }
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl), 0 0 40px rgba(0, 0, 0, 0.2);
    padding: var(--spacing-2xl);
    position: relative;
    z-index: 1;
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.login-logo img {
    width: 80px;
    height: 80px;
    margin-bottom: var(--spacing-md);
}

.login-logo h1 {
    font-size: 1.5rem;
    color: var(--primary-800);
    margin-bottom: var(--spacing-xs);
}

.login-logo p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ============================================
   LAYOUT - DASHBOARD
   ============================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.kd-sidebar-main,
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: width var(--transition-normal), transform var(--transition-normal);
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.sidebar::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.kd-sidebar-main.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand img {
    width: 40px;
    height: 40px;
}

.sidebar-brand h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-700);
    white-space: nowrap;
}

.sidebar-brand span {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.sidebar-nav {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
    /* Subtract sidebar-brand height */
}

.nav-section {
    margin-bottom: var(--spacing-lg);
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: var(--spacing-sm) var(--spacing-md);
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--primary-600);
}

.nav-link.active {
    background: var(--primary-50);
    color: var(--primary-700);
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.nav-link .badge {
    margin-left: auto;
}

/* Main Content */
.kd-main-layout,
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-normal);
    min-width: 0;
    /* Critical for flex child responsiveness */
    width: 100%;
}

.kd-sidebar-main.collapsed+.kd-main-layout,
.sidebar.collapsed+.main-content {
    margin-left: var(--sidebar-collapsed);
}

/* Navbar */
.kd-navbar-top,
.navbar {
    height: var(--navbar-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-lg);
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.navbar-toggle {
    background: none;
    border: none;
    padding: var(--spacing-sm);
    cursor: pointer;
    color: var(--primary-700);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--primary-600);
}

.navbar-toggle i,
.navbar-toggle svg,
.notification-btn i,
.notification-btn svg {
    width: 24px;
    height: 24px;
}


.page-title {
    font-size: 1.125rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

@media (min-width: 640px) {
    .page-title {
        max-width: none;
    }
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.user-menu:hover {
    background: var(--bg-tertiary);
}

.user-avatar {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    /* Prevent squeezing */
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--primary-200);
}

.user-info {
    text-align: right;
}

/* Notification Button */
.notification-dropdown {
    position: relative;
    display: flex;
    align-items: center;
}

.notification-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.notification-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary-600);
}

.notification-count {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-primary);
}

/* User Menu Container */
.user-menu-container {
    position: relative;
}


.user-name {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-role {
    font-size: 0.7rem;
    color: var(--primary-600);
    background: var(--primary-50);
    padding: 1px 8px;
    border-radius: 99px;
    display: inline-block;
    font-weight: 600;
    margin-top: 2px;
}

[data-theme="dark"] .user-role {
    background: rgba(37, 99, 235, 0.2);
    color: var(--primary-400);
}

/* Page Content */
.kd-page-body,
.page-content {
    padding: var(--spacing-xl);
}

.page-header {
    margin-bottom: var(--spacing-xl);
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    justify-content: space-between;
    align-items: center;
}

@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header .flex {
        width: 100%;
        justify-content: flex-start;
    }
}

.page-header h1 {
    margin-bottom: var(--spacing-xs);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--primary-600);
}

.breadcrumb span {
    color: var(--text-muted);
}

/* ============================================
   COMPONENTS - CARDS
   ============================================ */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

@media (max-width: 640px) {
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: var(--spacing-lg);
}

.card-footer {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* Stat Cards */
.stat-card,
.kd-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: var(--spacing-md);
    padding: var(--spacing-xl) var(--spacing-lg);
    min-width: 0;
}

/* Reduced mobile padding for more space */
@media (max-width: 480px) {

    .stat-card,
    .kd-stat-card {
        padding: var(--spacing-lg);
    }
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary {
    background: var(--primary-100);
    color: var(--primary-600);
}

.stat-icon.success {
    background: var(--success-light);
    color: var(--success);
}

.stat-icon.warning {
    background: var(--warning-light);
    color: var(--warning);
}

.stat-icon.danger {
    background: var(--danger-light);
    color: var(--danger);
}

.stat-icon.info {
    background: var(--info-light);
    color: var(--info);
}

.stat-content h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.stat-content p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}

.stat-change {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

/* ============================================
   COMPONENTS - FORMS
   ============================================ */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.form-label.required::after {
    content: '*';
    color: var(--danger);
    margin-left: 4px;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control.error {
    border-color: var(--danger);
}

.form-control.error:focus {
    box-shadow: 0 0 0 3px var(--danger-light);
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 4px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
}

.form-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-600);
    cursor: pointer;
}

.form-check label {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Input Group */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    border-radius: 0;
}

.input-group .form-control:first-child {
    border-top-left-radius: var(--radius-md);
    border-bottom-left-radius: var(--radius-md);
}

.input-group .form-control:last-child {
    border-top-right-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ============================================
   COMPONENTS - BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-800) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    color: white;
}

.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--primary-600);
    color: var(--primary-600);
}

.btn-outline-primary:hover {
    background: var(--primary-50);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--primary-600);
}

/* ============================================
   COMPONENTS - BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-full);
}

.badge-primary {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.badge-success {
    background: var(--success-light);
    color: #065f46;
}

.badge-warning {
    background: var(--warning-light);
    color: #92400e;
}

.badge-danger {
    background: var(--danger-light);
    color: #991b1b;
}

.badge-info {
    background: var(--info-light);
    color: #1e40af;
}

/* ============================================
   COMPONENTS - TABLES
   ============================================ */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-secondary);
}

.table tbody tr:hover {
    background: var(--bg-tertiary);
}

.table td {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

/* ============================================
   COMPONENTS - ALERTS
   ============================================ */
.alert {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.alert-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.alert-message {
    font-size: 0.875rem;
    margin: 0;
}

.alert-success {
    background: var(--success-light);
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.alert-warning {
    background: var(--warning-light);
    border: 1px solid #fde68a;
    color: #92400e;
}

.alert-danger {
    background: var(--danger-light);
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-info {
    background: var(--info-light);
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

/* ============================================
   COMPONENTS - MODALS
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--danger);
}

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* ============================================
   COMPONENTS - PROGRESS BAR
   ============================================ */
.progress {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.progress-bar.primary {
    background: linear-gradient(90deg, var(--primary-500), var(--primary-600));
}

.progress-bar.success {
    background: linear-gradient(90deg, var(--success), #059669);
}

.progress-bar.warning {
    background: linear-gradient(90deg, var(--warning), #d97706);
}

.progress-bar.danger {
    background: linear-gradient(90deg, var(--danger), #dc2626);
}

.progress-lg {
    height: 12px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    margin-bottom: var(--spacing-sm);
}

/* ============================================
   GRID SYSTEM
   ============================================ */
.grid {
    display: grid;
    gap: var(--spacing-lg);
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1200px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Flex utilities */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.gap-1 {
    gap: var(--spacing-xs);
}

.gap-2 {
    gap: var(--spacing-sm);
}

.gap-3 {
    gap: var(--spacing-md);
}

.gap-4 {
    gap: var(--spacing-lg);
}

/* Spacing utilities */
.m-0 {
    margin: 0;
}

.mt-1 {
    margin-top: var(--spacing-xs);
}

.mt-2 {
    margin-top: var(--spacing-sm);
}

.mt-3 {
    margin-top: var(--spacing-md);
}

.mt-4 {
    margin-top: var(--spacing-lg);
}

.mb-1 {
    margin-bottom: var(--spacing-xs);
}

.mb-2 {
    margin-bottom: var(--spacing-sm);
}

.mb-3 {
    margin-bottom: var(--spacing-md);
}

.mb-4 {
    margin-bottom: var(--spacing-lg);
}

.p-0 {
    padding: 0;
}

.p-2 {
    padding: var(--spacing-sm);
}

.p-3 {
    padding: var(--spacing-md);
}

.p-4 {
    padding: var(--spacing-lg);
}

/* ============================================
   NOTIFICATIONS DROPDOWN
   ============================================ */
.notification-dropdown {
    position: relative;
}

.notification-btn {
    position: relative;
    background: none;
    border: none;
    padding: var(--spacing-sm);
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.notification-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary-600);
}

.notification-count {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 18px;
    height: 18px;
    background: var(--danger);
    color: white;
    font-size: 0.625rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {

    .kd-sidebar-main,
    .sidebar {
        transform: translateX(-100%);
    }

    .kd-sidebar-main.open,
    .sidebar.open {
        transform: translateX(0);
    }

    .kd-main-layout,
    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 768px) {

    .kd-page-body,
    .page-content {
        padding: var(--spacing-md);
    }

    .grid {
        gap: var(--spacing-md);
    }

    .flex-wrap-mobile {
        flex-wrap: wrap !important;
    }

    .card-body,
    .card-header {
        padding: var(--spacing-md);
    }

    .kd-navbar-top,
    .navbar {
        padding: 0 var(--spacing-md);
    }

    .page-header {
        margin-bottom: var(--spacing-lg);
    }

    /* Fullscreen Login on Mobile */
    .login-container {
        padding: 0;
        background: white;
        /* Remove blue gradient */
    }

    .login-container::before {
        display: none;
        /* Remove animated grid background */
    }

    .login-card {
        padding: var(--spacing-lg);
        max-width: none;
        width: 100%;
        height: 100vh;
        border-radius: 0;
        box-shadow: none;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .table th,
    .table td {
        padding: 0.625rem 0.75rem;
        font-size: 0.8125rem;
    }

    .breadcrumb {
        flex-wrap: wrap;
        font-size: 0.75rem;
    }

    .breadcrumb i,
    .breadcrumb svg {
        width: 14px;
        height: 14px;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-slide-up {
    animation: slideInUp 0.3s ease-out;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

/* Loading Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {

    .sidebar,
    .navbar,
    .btn,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .page-content {
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* ============================================
   COMPONENTS - AVATARS
   ============================================ */
.avatar-sm {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: var(--radius-full);
}

.avatar-md {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-full);
}

.avatar-lg {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: var(--radius-full);
}

.rounded-circle {
    border-radius: var(--radius-full);
}

/* ============================================
   COMPONENTS - GRID
   ============================================ */
.grid {
    display: grid;
    gap: var(--spacing-lg);
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-lg);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-lg);
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-lg);
}

@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Navbar Toggle Button */
.navbar-toggle {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.navbar-toggle:hover {
    background-color: var(--bg-secondary);
    color: var(--primary);
}

/* Dropdown Menu Styles */
.user-menu-container .dropdown-menu {
    display: none;
    /* Hidden by default */
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 12rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    flex-direction: column;
}

code {
    font-family: var(--font-mono);
    background: var(--bg-tertiary);
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    color: var(--primary-700);
}

[data-theme="dark"] code {
    color: var(--primary-400);
}

.user-menu-container .dropdown-menu.visible {
    display: flex !important;
    /* Force display when active */
}



/* ============================================
   RESPONSIVE NAVIGATION SYSTEM (FINAL FIXED)
   ============================================ */

/* 1. Desktop & Large Screens (PC) */
@media (min-width: 1025px) {

    /* Hide Sidebar Toggle on Desktop as per User Request */
    #kdSidebarToggle {
        display: none !important;
    }
}

/* 2. Mobile & Tablet Screens */
@media (max-width: 768px) {

    .kd-navbar-top,
    .navbar {
        padding: 0 0.75rem;
    }

    /* Mobile Sidebar Toggle - Positioned Left */
    #kdSidebarToggle {
        display: flex !important;
    }

    /* Clean Icon Styling for Mobile (No Frames) */
    .navbar-toggle,
    .notification-btn {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 36px !important;
        height: 36px !important;
        background-color: transparent !important;
        border: none !important;
        color: var(--text-primary) !important;
        align-items: center;
        justify-content: center;
        z-index: 50;
        box-shadow: none !important;
        transition: all 0.2s ease;
    }

    .navbar-right {
        gap: var(--spacing-xs) !important;
    }

    .user-avatar {
        border: none !important;
        width: 32px !important;
        height: 32px !important;
    }

    .user-menu {
        padding: var(--spacing-xs) !important;
    }

    .notification-btn:active,
    #kdThemeToggle:active {
        transform: scale(0.9);
        opacity: 0.7;
    }

    /* Ensure Icons are Visible */
    .navbar-toggle svg,
    .notification-btn svg {
        width: 24px !important;
        height: 24px !important;
        stroke: currentColor !important;
        stroke-width: 2px;
    }

    .notification-dropdown {
        margin-right: 0;
    }

    /* 3. Mobile Dropdown Menu Fixes */
    .user-menu-container .dropdown-menu {
        position: absolute !important;
        top: calc(100% + 10px) !important;
        right: -8px !important;
        /* Prevent horizontal overflow */
        width: 280px !important;
        max-width: 90vw !important;
        border: 1px solid #e2e8f0;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        border-radius: 12px;
        overflow: hidden;
        z-index: 1050;
        background-color: #ffffff;
    }

    /* Mobile Typography for User Info in Dropdown */
    .dropdown-menu .md\:hidden {
        display: block !important;
        background-color: #f8fafc;
        padding: 16px !important;
        border-bottom: 1px solid #e2e8f0;
    }

    .dropdown-menu .md\:hidden .font-bold {
        font-size: 0.95rem !important;
        font-weight: 700 !important;
        color: #0f172a;
        margin-bottom: 4px;
        line-height: 1.3;
        display: block;
    }

    .dropdown-menu .md\:hidden .text-muted {
        font-size: 0.8rem !important;
        color: #64748b;
        display: block;
    }
}

/* 3. Utility Classes (Ensure they work everywhere) */
.hidden {
    display: none !important;
}

.relative {
    position: relative !important;
}

.absolute {
    position: absolute !important;
}

.block {
    display: block !important;
}

.flex {
    display: flex !important;
}

.items-center {
    align-items: center !important;
}

.justify-between {
    justify-content: space-between !important;
}

.gap-2 {
    gap: 0.5rem !important;
}

.mr-3 {
    margin-right: 0.75rem !important;
}

.mt-2 {
    margin-top: 0.5rem !important;
}

/* Removed problematic utility overrides */

.rounded-full {
    border-radius: 9999px !important;
}

.cursor-pointer {
    cursor: pointer !important;
}

.text-right {
    text-align: right !important;
}

.text-center {
    text-align: center !important;
}

.text-left {
    text-align: left !important;
}

/* Spacing & Layout Utilities */
.mx-auto {
    margin-left: auto !important;
    margin-right: auto !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: 0.25rem !important;
}

.mb-2 {
    margin-bottom: 0.5rem !important;
}

.mb-3 {
    margin-bottom: 0.75rem !important;
}

.mb-4 {
    margin-bottom: 1rem !important;
}

.mb-6 {
    margin-bottom: 1.5rem !important;
}

.mb-8 {
    margin-bottom: 2rem !important;
}

.mt-1 {
    margin-top: 0.25rem !important;
}

.mt-4 {
    margin-top: 1rem !important;
}

.mt-6 {
    margin-top: 1.5rem !important;
}

.p-0 {
    padding: 0 !important;
}

.p-5 {
    padding: 1.25rem !important;
}

.p-8 {
    padding: 2rem !important;
}

.py-1 {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
}

.px-0 {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.px-3 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
}

.gap-3 {
    gap: 0.75rem !important;
}

.gap-4 {
    gap: 1rem !important;
}

.gap-8 {
    gap: 2rem !important;
}

.flex-1 {
    flex: 1 1 0% !important;
}

.flex-shrink-0 {
    flex-shrink: 0 !important;
}

/* Grid Utilities */
.grid {
    display: grid !important;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

.col-span-1 {
    grid-column: span 1 / span 1 !important;
}

.col-span-2 {
    grid-column: span 2 / span 2 !important;
}

@media (max-width: 768px) {

    .grid-2,
    .grid-3 {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }

    .col-span-1,
    .col-span-2 {
        grid-column: span 1 / span 1 !important;
    }
}

/* Typography & Colors */
.text-xs {
    font-size: 0.75rem !important;
}

.text-sm {
    font-size: 0.875rem !important;
}

.text-lg {
    font-size: 1.125rem !important;
}

.text-xl {
    font-size: 1.25rem !important;
}

.text-2xl {
    font-size: 1.5rem !important;
}

.font-medium {
    font-weight: 500 !important;
}

.font-bold {
    font-weight: 700 !important;
}

.truncate {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.uppercase {
    text-transform: uppercase !important;
}

.leading-relaxed {
    line-height: 1.625 !important;
}

.text-primary {
    color: var(--primary-600) !important;
}

.text-success {
    color: var(--success) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-info {
    color: var(--info) !important;
}

.text-gray-500 {
    color: var(--gray-500) !important;
}

.text-gray-600 {
    color: var(--gray-600) !important;
}

.text-gray-900 {
    color: var(--gray-900) !important;
}

/* BG Utilities */
.bg-primary-600 {
    background-color: var(--primary-600) !important;
}

.bg-gray-50 {
    background-color: var(--gray-50) !important;
}

.bg-info-light {
    background-color: var(--info-light) !important;
}

.bg-success-light {
    background-color: var(--success-light) !important;
}

.bg-warning-light {
    background-color: var(--warning-light) !important;
}

.bg-danger-light {
    background-color: var(--danger-light) !important;
}

/* Sizing */
.w-4 {
    width: 1rem !important;
}

.w-5 {
    width: 1.25rem !important;
}

.w-8 {
    width: 2rem !important;
}

.w-10 {
    width: 2.5rem !important;
}

.w-32 {
    width: 8rem !important;
}

.h-4 {
    height: 1rem !important;
}

.h-5 {
    height: 1.25rem !important;
}

.h-8 {
    height: 2rem !important;
}

.h-10 {
    height: 2.5rem !important;
}

.h-32 {
    height: 8rem !important;
}

.max-w-4xl {
    max-width: 56rem !important;
}

/* Visuals */
.shadow-md {
    box-shadow: var(--shadow-md) !important;
}

.shadow-lg {
    box-shadow: var(--shadow-lg) !important;
}

.border-4 {
    border-width: 4px !important;
}

.border-white {
    border-color: white !important;
}

.border-gray-100 {
    border-color: var(--gray-100) !important;
}

.border-top {
    border-top-width: 1px !important;
}

.transition-transform {
    transition-property: transform !important;
    transition-duration: 200ms !important;
}

.transition-colors {
    transition-property: background-color, border-color, color, fill, stroke !important;
    transition-duration: 200ms !important;
}

.group:hover .group-hover\:scale-105 {
    transform: scale(1.05) !important;
}

.btn-block {
    width: 100% !important;
}

.btn-ghost:hover {
    background-color: rgba(0, 0, 0, 0.05) !important;
}

@media (min-width: 769px) {
    .md\:block {
        display: block !important;
    }

    .md\:hidden {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .hidden.md\:block {
        display: none !important;
    }

    .md\:hidden {
        display: block !important;
    }
}

/* Ensure dropdown links are clickable and visible */
.dropdown-menu a {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background-color 0.2s;
}

.dropdown-menu a:hover {
    background-color: var(--bg-secondary);
    color: var(--primary);
}