/* ==========================================================================
   BRENER GROUP - DESIGN SYSTEM & APP STYLES
   ========================================================================== */

/* --- CSS Variables & Themes --- */
:root {
    /* Color Palette - Dark Theme (Default) */
    --bg-main: #0a0d14;
    --bg-sidebar: rgba(13, 17, 28, 0.85);
    --bg-topbar: rgba(13, 17, 28, 0.8);
    --bg-card: rgba(21, 29, 45, 0.5);
    --bg-card-hover: rgba(29, 39, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.07);
    --border-color-focus: rgba(204, 163, 82, 0.5);
    
    --primary: #cca352; /* Gold/Bronze */
    --primary-hover: #b58d3d;
    --primary-rgb: 204, 163, 82;
    
    --secondary: #3b82f6; /* Electric Blue */
    --secondary-hover: #2563eb;
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #111827;
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    
    --font-family: 'Outfit', sans-serif;
    --sidebar-width: 280px;
    --topbar-height: 75px;
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.25);
    --glass-blur: blur(16px);
}

body.light-mode {
    /* Color Palette - Light Theme */
    --bg-main: #f4f6fa;
    --bg-sidebar: rgba(255, 255, 255, 0.9);
    --bg-topbar: rgba(255, 255, 255, 0.85);
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-color-focus: rgba(181, 141, 61, 0.5);
    
    --primary: #b58d3d;
    --primary-hover: #9c752b;
    --primary-rgb: 181, 141, 61;
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.08);
}

/* --- Base & Reset Rules --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    text-decoration: none;
    color: inherit;
}

input, button, select, textarea {
    font-family: inherit;
    font-size: inherit;
    background: none;
    border: none;
    outline: none;
    color: inherit;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(var(--primary-rgb), 0.3);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* --- Layout Wrapper --- */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 12px;
}

/* Light mode logo inversion to turn white transparent logo to black */
body.light-mode #sidebarLogoImg {
    filter: brightness(0);
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), #ebd197);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dark);
    font-weight: 800;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-brand {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 1px;
    color: var(--text-main);
}

.logo-sub {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 3px;
    color: var(--primary);
    margin-top: -3px;
}

.mobile-close-btn {
    display: none;
    color: var(--text-muted);
    cursor: pointer;
}

/* Menu Search */
.menu-search {
    padding: 12px 20px;
    position: relative;
    border-bottom: 1px solid var(--border-color);
}

.menu-search input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 8px 12px 8px 40px !important;
    border-radius: 8px;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

body.light-mode .menu-search input {
    background: rgba(0, 0, 0, 0.03);
}

.menu-search input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.menu-search .search-icon {
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Nav Menu & Groups */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-group {
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.nav-group-title {
    padding: 10px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}

.nav-group-title:hover {
    color: var(--primary);
}

.group-arrow {
    transition: transform 0.2s ease;
    opacity: 0.6;
}

.nav-group-items {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0 8px 8px;
}

/* Active Group behavior */
.nav-group.active .nav-group-items {
    display: flex;
}

.nav-group.active .group-arrow {
    transform: rotate(180deg);
    color: var(--primary);
}

/* Nav Item */
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

body.light-mode .nav-item:hover {
    background: rgba(0, 0, 0, 0.02);
}

.nav-item.active {
    color: var(--text-dark);
    background: linear-gradient(135deg, var(--primary), #ebd197);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.15);
}

.nav-item.active .nav-icon svg {
    color: var(--text-dark);
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
}

.nav-icon svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.nav-item:hover .nav-icon svg {
    color: var(--primary);
}

/* Sidebar Footer Controls */
.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.footer-control-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    width: 100%;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.footer-control-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
}

body.light-mode .footer-control-btn:hover {
    background: rgba(0, 0, 0, 0.03);
}

.footer-control-btn.logout:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

.control-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Main Layout Wrapper --- */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Topbar Header --- */
.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-topbar);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

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

.mobile-toggle-btn {
    display: none;
    color: var(--text-muted);
    cursor: pointer;
}

.topbar-title-wrapper {
    display: flex;
    flex-direction: column;
}

.topbar-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.topbar-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

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

/* Custom Select Dropdown */
.custom-select {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

body.light-mode .custom-select {
    background: rgba(0, 0, 0, 0.03);
}

.custom-select:hover {
    border-color: var(--primary);
}

.custom-select option {
    background: var(--bg-main);
    color: var(--text-main);
}

/* Topbar Action Icon Button */
.topbar-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    position: relative;
    transition: all 0.2s ease;
}

.topbar-action-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.06);
}

.badge-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-topbar);
    display: none;
}

/* Notifications Dropdown */
.notification-badge-container {
    position: relative;
}

.notification-dropdown {
    position: absolute;
    right: 0;
    top: 50px;
    width: 320px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideInDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
}

.notification-dropdown.active {
    display: flex;
}

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

.dropdown-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.mark-all-read {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
}

.dropdown-body {
    max-height: 280px;
    overflow-y: auto;
}

.noti-item {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.noti-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.noti-item.unread {
    background: rgba(var(--primary-rgb), 0.05);
}

.noti-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 3px;
}

.noti-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.noti-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 6px;
    align-self: flex-end;
}

/* User Profile button */
.profile-quick-view {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px 6px 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-quick-view:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--primary);
}

.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #ebd197);
    color: var(--text-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: var(--shadow-sm);
}

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

.profile-name {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
}

.profile-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* --- Content Container --- */
.content-container {
    padding: 32px;
    flex: 1;
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
}

/* Loading Spinner */
.loading-spinner-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    gap: 16px;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(var(--primary-rgb), 0.2);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ==========================================================================
   UI COMPONENTS
   ========================================================================== */

/* --- Card Grid Layout --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.grid-2col {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    align-items: start;
    margin-bottom: 32px;
}

.grid-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

@media (max-width: 1200px) {
    .grid-2col {
        grid-template-columns: 1fr;
    }
    .grid-3col {
        grid-template-columns: 1fr;
    }
}

/* --- Premium Card Style --- */
.card {
    background-color: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title svg {
    color: var(--primary);
}

.card-action {
    display: flex;
    gap: 8px;
}

/* Metric / Stat Card variant */
.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
}

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

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-val {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 4px 0;
    color: var(--text-main);
}

.stat-desc {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-desc.up { color: var(--success); }
.stat-desc.down { color: var(--danger); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

/* --- Forms & Inputs --- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
select,
textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: all 0.2s ease;
}

body.light-mode input[type="text"],
body.light-mode input[type="number"],
body.light-mode input[type="date"],
body.light-mode input[type="email"],
body.light-mode select,
body.light-mode textarea {
    background: rgba(0, 0, 0, 0.02);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #ebd197);
    color: var(--text-dark);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.15);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.25);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn-warning {
    background: var(--warning);
    color: #111;
}

.btn-warning:hover {
    background: #d97706;
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #059669;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* --- Tables --- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

th {
    background: rgba(255, 255, 255, 0.02);
    padding: 14px 18px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

body.light-mode th {
    background: rgba(0, 0, 0, 0.01);
}

td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

/* --- Progress Bar --- */
.progress-container {
    width: 100%;
    margin-top: 8px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

body.light-mode .progress-bar-bg {
    background: rgba(0, 0, 0, 0.06);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #ebd197);
    border-radius: 4px;
    width: 0;
    transition: width 0.5s ease;
}

/* --- Badge / Status Pill --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-primary { background: rgba(var(--primary-rgb), 0.15); color: var(--primary); }
.badge-secondary { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }

/* ==========================================================================
   AI ASSISTANT FLOATING CHAT WIDGET
   ========================================================================== */
.floating-ai-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
}

.ai-trigger-btn {
    height: 52px;
    border-radius: 26px;
    background: linear-gradient(135deg, var(--primary), #ebd197);
    box-shadow: 0 8px 32px rgba(var(--primary-rgb), 0.3);
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dark);
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ai-trigger-btn:hover {
    transform: scale(1.05) translateY(-3px);
    box-shadow: 0 12px 40px rgba(var(--primary-rgb), 0.45);
}

.ai-sparkle svg {
    animation: rotateSparkle 4s linear infinite;
}

.ai-chat-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 360px;
    height: 480px;
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: popUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-chat-panel.active {
    display: flex;
}

.ai-chat-header {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-logo-dot {
    width: 10px;
    height: 10px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--success);
}

.ai-chat-title h4 {
    font-size: 0.9rem;
    font-weight: 700;
}

.ai-chat-title span {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.ai-chat-close {
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
}

.ai-chat-close:hover {
    color: var(--danger);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.4;
    max-width: 85%;
    word-break: break-word;
}

.message.ai {
    background: rgba(255, 255, 255, 0.04);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    border: 1px solid var(--border-color);
}

body.light-mode .message.ai {
    background: rgba(0, 0, 0, 0.02);
}

.message.user {
    background: linear-gradient(135deg, var(--primary), #ebd197);
    color: var(--text-dark);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
    font-weight: 500;
}

.ai-chat-input-area {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

.ai-chat-input-area input {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.85rem;
}

.ai-chat-input-area button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-chat-input-area button:hover {
    transform: scale(1.05);
}

/* ==========================================================================
   MODAL SYSTEM & TOASTS
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 600px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    animation: popUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

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

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-close {
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 24px;
    max-height: 80vh;
    overflow-y: auto;
}

/* Toast Messages */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    padding: 12px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    min-width: 250px;
    max-width: 350px;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.toast-border {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.toast-success { color: var(--success); }
.toast-success .toast-border { background-color: var(--success); }
.toast-danger { color: var(--danger); }
.toast-danger .toast-border { background-color: var(--danger); }
.toast-warning { color: var(--warning); }
.toast-warning .toast-border { background-color: var(--warning); }

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes slideInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes rotateSparkle {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.1); }
    100% { transform: rotate(360deg) scale(1); }
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE ADAPTATION)
   ========================================================================== */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-wrapper {
        margin-left: 0;
    }
    
    .mobile-toggle-btn {
        display: flex;
    }
    
    .mobile-close-btn {
        display: flex;
    }
    
    .topbar {
        padding: 0 16px;
    }
    
    .content-container {
        padding: 20px 16px;
    }
    
    .floating-ai-widget {
        bottom: 20px;
        right: 20px;
    }
    
    .ai-chat-panel {
        width: calc(100vw - 40px);
    }
}

/* ==========================================================================
   AUTHENTICATION & LOGIN OVERLAY (HIGH CONTRAST & LEGIBILITY)
   ========================================================================== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    /* Premium colorful gold-blue mesh background */
    background: radial-gradient(circle at 10% 20%, rgba(235, 209, 151, 0.12) 0%, transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(235, 209, 151, 0.08) 0%, transparent 50%),
                linear-gradient(135deg, #162235 0%, #0c1322 100%);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    overflow-y: auto;
    color: #ffffff; /* Explicit white color for all text inside overlay */
}

body.auth-mode .login-overlay {
    display: flex;
}

body.auth-mode .app-container,
body.auth-mode .floating-ai-widget {
    display: none !important;
}

.login-card {
    background: rgba(15, 23, 42, 0.65); /* Elegant translucent slate-900 */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(235, 209, 151, 0.25); /* Gold brand border */
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 440px;
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5),
                0 0 40px rgba(235, 209, 151, 0.04); /* Soft gold glow */
    animation: fadeIn 0.4s ease;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 20px;
}

.login-logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), #ebd197);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111827; /* Rich dark grey icon letter */
    font-weight: 800;
    font-size: 1.6rem;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.login-logo h2 {
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: 1px;
    color: #ffffff !important; /* Force high contrast white logo name */
}

.login-logo p {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--primary) !important;
    margin-top: -2px;
}

.login-card label {
    color: #ebd197 !important; /* Elegant high-contrast light gold/cream label */
    font-weight: 600;
    font-size: 0.85rem;
}

.login-card input[type="email"],
.login-card input[type="password"] {
    background: rgba(0, 0, 0, 0.4) !important; /* Dark solid input background */
    border: 1px solid rgba(255, 255, 255, 0.3) !important; /* Highly visible input border */
    color: #ffffff !important; /* Pure white text inside inputs */
    padding: 12px 14px;
    font-size: 0.95rem;
    font-weight: 500;
    margin-top: 6px;
}

.login-card input::placeholder {
    color: #94a3b8 !important; /* Bright Slate 400 placeholder text */
    opacity: 1; /* Reset browser opacity override */
}

.login-helper {
    margin-top: 32px;
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
    padding-top: 20px;
}

.login-helper h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: #cbd5e1 !important; /* High contrast light grey header */
    margin-bottom: 12px;
}

.helper-accounts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.helper-accounts-grid button {
    background: rgba(255, 255, 255, 0.08) !important; /* More solid helper button background */
    border: 1px solid rgba(255, 255, 255, 0.2) !important; /* Visible border */
    color: #ffffff !important; /* High contrast white text for helper buttons */
    padding: 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

.helper-accounts-grid button:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
}

/* ==========================================================================
   ROLE PERMISSION MATRIX TABLE
   ========================================================================== */
.matrix-table {
    width: 100%;
    margin-top: 20px;
}

.matrix-table th {
    text-align: center;
}

.matrix-table th:first-child {
    text-align: left;
}

.matrix-table td {
    text-align: center;
}

.matrix-table td:first-child {
    text-align: left;
    font-weight: 600;
}

.matrix-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ==========================================================================
   ADVANCED TEKNİK ŞARTNAME EDIT & DRAG STYLING
   ========================================================================== */
.clause-row {
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.clause-row:hover {
    border-color: rgba(204, 163, 82, 0.5) !important;
    background: rgba(255, 255, 255, 0.04) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
body.light-mode .clause-row:hover {
    background: rgba(0, 0, 0, 0.02) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.clause-row input.clause-title {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
}
body.light-mode .clause-row input.clause-title {
    background: rgba(0, 0, 0, 0.01);
    border-color: rgba(0, 0, 0, 0.1);
}
.clause-row textarea.clause-content {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    border-radius: 6px;
    font-family: inherit;
    resize: vertical;
    width: 100%;
}
body.light-mode .clause-row textarea.clause-content {
    background: rgba(0, 0, 0, 0.01);
    border-color: rgba(0, 0, 0, 0.08);
}
.clause-row textarea.clause-content:focus,
.clause-row input.clause-title:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
    outline: none;
}
body.light-mode .clause-row textarea.clause-content:focus,
body.light-mode .clause-row input.clause-title:focus {
    background: #ffffff;
}
#specUploadZone:hover {
    background: rgba(204, 163, 82, 0.05) !important;
    border-color: var(--primary) !important;
    transform: scale(1.01);
}
#specUploadZone:active {
    transform: scale(0.99);
}
#specsA4Preview {
    font-family: 'Outfit', 'Inter', sans-serif !important;
    border: 1px solid rgba(0,0,0,0.1);
}
body.light-mode #specsA4Preview {
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

