:root {
    /* Clean White Theme Variables */
    --bg-page: #f8fafc;
    /* Slate 50 */
    --bg-surface: #ffffff;
    /* Pure white */
    --primary: #0f172a;
    /* Slate 900 */
    --accent: #3b82f6;
    /* Blue accent */

    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-light: #e2e8f0;
    /* Slate 200 */

    --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);

    --sidebar-width: 260px;
    --header-height: 70px;
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* SIDEBAR (Power BI Style) */
.pbi-sidebar {
    background: #ffffff;
    /* White clean background */
    width: 68px;
    border-right: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0;
    z-index: 50;
    flex-shrink: 0;
    height: 100%;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 0.5rem;
}

.sidebar-item {
    width: 100%;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #444;
    text-decoration: none;
    transition: background 0.2s;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.sidebar-item:hover {
    background-color: #f8fafc;
    /* Subtle hover */
}

.sidebar-item.active {
    background-color: #f1f5f9;
    /* Light active state */
    border-left-color: var(--accent);
    color: var(--accent);
}

.sidebar-label {
    font-size: 0.65rem;
    margin-top: 4px;
    text-align: center;
    line-height: 1;
}

.logo-item {
    color: var(--accent);
    margin-bottom: 0.5rem;
    height: 50px;
}

.sidebar-divider {
    height: 1px;
    width: 40px;
    background: #ccc;
    margin: 0.5rem 0;
}

.sidebar-bottom {
    padding-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    /* For popup menu anchor */
}

/* PROFILE & MENU */
.avatar-circle {
    width: 32px;
    height: 32px;
    background: #d1d5db;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #374151;
    font-size: 0.8rem;
    cursor: pointer;
}

.profile-menu {
    position: fixed;
    bottom: 20px;
    left: 74px;
    /* Right next to sidebar */
    width: 240px;
    background: white;
    border: 1px solid #e5e5e5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    padding: 0;
    display: none;
    /* Toggled by JS */
    z-index: 2000;
}

.menu-header {
    padding: 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e5e5e5;
}

.menu-header strong {
    display: block;
    font-size: 0.9rem;
}

.menu-header small {
    display: block;
    color: #64748b;
    font-size: 0.8rem;
}

.menu-item {
    display: block;
    padding: 0.75rem 1rem;
    color: #334155;
    text-decoration: none;
    font-size: 0.9rem;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.menu-item:hover {
    background: #f1f5f9;
}

.text-danger {
    color: #ef4444;
}

.menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: transparent;
}


/* LAYOUT */
.main-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    background-color: #faf9f8;
    /* Power BI Off-white */
}

.top-header {
    height: 56px;
    /* Slimmer header */
    background: #ffffff;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    gap: 1rem;
    width: 100%;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 150px;
}

.brand-text {
    font-weight: 600;
    color: #323130;
    font-size: 1rem;
}

.brand-sub {
    color: #605e5c;
    font-size: 0.9rem;
    padding-left: 0.5rem;
    border-left: 1px solid #ccc;
}

.search-bar-container {
    flex: 1;
    max-width: 400px;
    position: relative;
    margin: 0 auto;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.search-input-wrapper svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #94a3b8;
    z-index: 10;
}

.search-input-wrapper input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.8rem;
    /* Compact padding */
    border: 1px solid #e2e8f0;
    background-color: #f1f5f9;
    /* Darker background for visibility */
    border-radius: 50px;
    font-size: 0.9rem;
    color: #334155;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.search-input-wrapper input:focus {
    background-color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    padding: 0.5rem 1rem 0.5rem 2.8rem;
    /* Keep padding consistent */
}

.search-input-wrapper input::placeholder {
    color: #cbd5e1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-display {
    font-size: 0.9rem;
    font-weight: 600;
    color: #323130;
}

.avatar-circle-sm {
    width: 28px;
    height: 28px;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
}

.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* PAGE HEADERS */
.page-header {
    margin-bottom: 2rem;
}

.page-title-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    line-height: 1.2;
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0 0;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0 0 1rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #f1f5f9;
}

/* CARDS */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.db-card {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid #f1f5f9;
    /* Lighter border for clean look */
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

a.db-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.db-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #f0fdf4;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.page-cols {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.col-2 {
    flex: 2;
}

.col-1 {
    flex: 1;
}

@media (max-width: 1024px) {
    .page-cols {
        flex-direction: column;
    }
}

/* IFRAME */
.iframe-wrapper {
    background: var(--bg-surface);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    height: 100%;
    overflow: hidden;
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* LOGIN */
/* LOGIN REDESIGN */
.login-screen {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
}

.login-container {
    display: flex;
    width: 960px;
    height: 640px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    /* Subtle White to Slate Gradient */
    border-radius: 24px;
    box-shadow:
        0 20px 25px -5px rgb(0 0 0 / 0.1),
        0 8px 10px -6px rgb(0 0 0 / 0.1);
    overflow: hidden;
    /* Clips the hero image at corners */
}

.mobile-hero-image {
    display: none;
    /* Hidden on desktop */
}

.login-hero {
    flex: 1.2;
    /* Give image slightly more space */
    background: url('../images/login-hero.png') no-repeat center center;
    background-size: 80%;
    /* Adjusted for card size */
    background-color: transparent;
    position: relative;
    /* geometric background optional */
}

/* Optional: Add circles/lines via pseudo-elements if needed later, keeping simple for now */

.login-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.login-box {
    width: 100%;
    max-width: 380px;
    background: transparent;
    /* Removed individual card styles since container is the card now */
}


.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.375rem;
}

.form-input {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    margin-top: 0.3rem;
}

.btn-primary {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 0.8s linear infinite;
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* RESPONSIVE */
@media (max-width: 1024px) {
    .login-container {
        width: 90%;
        height: auto;
        min-height: 500px;
    }
}

@media (max-width: 960px) {
    .login-container {
        flex-direction: column;
        /* Normal direction because img is first child now */
        width: 90%;
        max-width: 450px;
        /* Limit width on tablets */
        height: auto;
        min-height: auto;
        border-radius: 16px;
        overflow: hidden;
    }

    /* Hide the CSS background div on mobile */
    .login-hero {
        display: none !important;
    }

    .mobile-hero-image {
        display: none !important;
    }

    .login-form-side {
        padding: 2rem 1.5rem;
        /* Reduce padding */
    }

    .login-box {
        padding: 0;
        max-width: 100%;
    }
}

/* Extra small devices (phones, 600px and down) */
@media (max-width: 600px) {
    .login-container {
        width: 92%;
        /* Breathing room on sides */
        max-width: 400px;
        background: #ffffff;
        border-radius: 16px;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        margin: 0 auto;
    }

    .login-screen {
        background-color: #f1f5f9;
        /* Contrast background */
        align-items: center;
        /* Center vertically */
        padding: 1rem;
    }

    .login-form-side {
        padding: 1.5rem;
    }
}





/* SWEETALERT CUSTOMIZATION */
.swal-custom-popup {
    border-radius: 16px !important;
    padding: 1.25rem !important;
    /* Reduced from 2rem */
    width: 380px !important;
    /* Fixed compact width */
}

.swal-custom-title {
    font-size: 1.1rem !important;
    /* Reduced from 1.25rem */
    color: #1a1a1a !important;
    font-weight: 700 !important;
    padding: 0 !important;
    /* Remove default title padding */
}

.swal-custom-text {
    color: #666666 !important;
    font-size: 0.9rem !important;
    margin-bottom: 0 !important;
}

.swal-custom-confirm {
    background-color: #000000 !important;
    color: #ffffff !important;
    border-radius: 6px !important;
    padding: 8px 16px !important;
    /* Reduced padding */
    font-weight: 500 !important;
    box-shadow: none !important;
    font-size: 0.85rem !important;
}

.swal-custom-confirm:focus {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.2) !important;
}

.swal-custom-cancel {
    background-color: #ffffff !important;
    color: #333333 !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 6px !important;
    padding: 8px 16px !important;
    /* Reduced padding */
    font-weight: 500 !important;
    margin-right: 0.5rem !important;
    /* Spacing between buttons */
    font-size: 0.85rem !important;
}

.swal-custom-cancel:hover {
    background-color: #f9fafb !important;
}

/* Adjust button container spacing */
.swal2-actions {
    gap: 0.5rem;
    margin-top: 1rem !important;
    width: 100%;
    justify-content: flex-end !important;
    /* Align buttons right like standard dialogs */
}

/* DATA TABLES */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 1rem;
}

.data-table th {
    text-align: left;
    padding: 0.85rem 1rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-light);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 0.85rem 1rem;
    color: var(--text-main);
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.data-table tr:hover {
    background-color: #f8fafc;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* BADGES */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.badge-success {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-neutral {
    background-color: #f1f5f9;
    color: #64748b;
}

/* ACTION BUTTONS */
.btn-action {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-edit {
    color: #3b82f6;
    background: transparent;
}

.btn-edit:hover {
    background: #eff6ff;
    text-decoration: none;
}

.btn-delete {
    color: #ef4444;
    background: transparent;
    border: 1px solid transparent;
}

.btn-delete:hover {
    background: #fef2f2;
    border-color: #fecaca;
}

.btn-assign {
    background: #3b82f6;
    color: white;
}

.btn-assign:hover {
    background: #2563eb;
    color: white;
}

/* MODALS */
@keyframes modalFadeIn {
    from { opacity: 0; backdrop-filter: blur(0px); }
    to { opacity: 1; backdrop-filter: blur(4px); }
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
    animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-overlay.active .modal-dialog {
    animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-dialog {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.btn-secondary {
    padding: 0.625rem 1rem;
    background: #f1f5f9;
    color: #64748b;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.page-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1.5rem;
}

.btn-create {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-create:hover {
    background: #1e293b;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

/* Lazy Loading for Dashboards */
.iframe-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    z-index: 5;
}

.spinner-pbi {
    width: 40px;
    height: 40px;
    border: 4px solid #f2c81122;
    border-top: 4px solid #f2c811;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.lazy-iframe {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.lazy-iframe.loaded {
    opacity: 1;
}