/* ============================================
   LOOKER STUDIO ALTERNATIVE - AL JAZEERA STYLE
   ============================================ */

/* CSS Variables - Color Palette from Reference */
:root {
    --primary-color: #190e66;
    --primary-light: #2d1a99;
    --accent-color: #d4a10f;
    --accent-light: #f9c065;
    --bg-color: #f5f6fa;
    --bg-light: #f8f9fe;
    --surface-color: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --success-color: #10b981;
    --success-light: #dcfce7;
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --danger-color: #ef4444;
    --danger-light: #fee2e2;
    --navbar-height: 88px;
    --sub-tab-bar-height: 44px;
    --sidebar-width: 280px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.04), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Tajawal', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    direction: rtl;
}

/* Navigation */
.navbar {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    padding: 0;
    box-shadow: 0 4px 20px rgba(25, 14, 102, 0.3), 0 2px 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 3px solid rgba(212, 161, 15, 0.3);
    backdrop-filter: blur(10px);
}

.navbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.1;
    pointer-events: none;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    position: relative;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex: 1;
    min-width: 0;
}

.logo-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.brand-text {
    font-size: 1.625rem;
    font-weight: 700;
    font-family: 'Cairo', sans-serif;
    background: linear-gradient(135deg, #ffffff 0%, var(--accent-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Tajawal', sans-serif;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    position: relative;
    overflow: hidden;
}

.nav-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.nav-btn:hover::before {
    left: 100%;
}

.nav-btn-export {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-light) 100%);
    color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(212, 161, 15, 0.4);
}

.nav-btn-export:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(212, 161, 15, 0.5);
}

.nav-btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: var(--transition);
}

.nav-btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.nav-btn-icon.refresh:hover {
    background: rgba(212, 161, 15, 0.3);
    border-color: rgba(212, 161, 15, 0.5);
}

.nav-btn-icon:hover .icon-spin {
    transform: rotate(180deg);
}

.icon-spin {
    transition: transform 0.5s ease;
}

/* User Profile Area */
.user-profile-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-right: auto;
    padding-right: 1.5rem;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.header-icons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    font-size: 1.1rem;
}

.header-icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: translateY(-2px);
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--primary-color);
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid rgba(255, 255, 255, 0.3);
    position: relative;
}

.user-avatar:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 15px rgba(212, 161, 15, 0.4);
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: var(--success-color);
    border-radius: 50%;
    border: 2px solid var(--primary-color);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    line-height: 1.2;
}

.user-role {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

.user-dropdown {
    position: relative;
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    padding: 0.75rem;
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
    z-index: 1100;
}

.user-dropdown:hover .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.dropdown-header .name {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.95rem;
}

.dropdown-header .email {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.75rem;
    border-radius: 10px;
    color: #4b5563;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: transparent;
    width: 100%;
    text-align: right;
    font-family: 'Tajawal', sans-serif;
}

.menu-item:hover {
    background: #f3f4f6;
    color: var(--primary-color);
}

.menu-item.logout {
    color: var(--danger-color);
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 0.85rem;
}

.menu-item.logout:hover {
    background: var(--danger-light);
}

/* Application Layout */
.app-shell {
    display: flex;
    min-height: calc(100vh - 80px);
    background: var(--bg-light);
    position: relative;
    padding-right: var(--sidebar-width);
    transition: padding-right 0.3s ease;
}

.app-shell.sidebar-collapsed {
    --sidebar-width: 80px;
    padding-right: var(--sidebar-width);
}

/* Side Panel */
.side-pane {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #100a3c 0%, #1a1147 50%, #0f0833 100%);
    color: white;
    padding: 2rem 0;
    position: fixed;
    top: var(--navbar-height);
    right: 0;
    height: calc(100vh - var(--navbar-height));
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.25), inset 1px 0 0 rgba(255, 255, 255, 0.05);
    z-index: 900;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 3px solid rgba(212, 161, 15, 0.2);
    transition: width 0.3s ease;
}

.app-shell.sidebar-collapsed .side-pane {
    width: var(--sidebar-width);
}

/* Hide text in collapsed mode */
.app-shell.sidebar-collapsed .side-nav-link span {
    display: none;
}

.app-shell.sidebar-collapsed .side-nav-link {
    justify-content: center;
    padding: 1rem 0;
}

/* Fix active state in collapsed mode */
.app-shell.sidebar-collapsed .side-nav-link.active {
    transform: none;
    padding: 1rem 0;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

.app-shell.sidebar-collapsed .side-nav-link.active::before {
    display: none;
}

.app-shell.sidebar-collapsed .side-nav-link:hover {
    transform: none;
    padding: 1rem 0;
}

.side-pane::-webkit-scrollbar {
    width: 6px;
}

.side-pane::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.side-pane::-webkit-scrollbar-thumb {
    background: rgba(212, 161, 15, 0.3);
    border-radius: 3px;
}

.side-pane-header {
    margin-bottom: 2.5rem;
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.side-pane-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 1.75rem;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    /* Prevent logo overflow */
}

.sidebar-logo {
    width: 140px !important;
    max-width: 140px !important;
    height: 50px !important;
    max-height: 50px !important;
    object-fit: contain;
    display: block;
}

.app-shell.sidebar-collapsed .sidebar-logo {
    display: none;
}

.app-shell.sidebar-collapsed .header-content {
    justify-content: center;
}

.sidebar-toggle-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    transition: color 0.3s;
}

.sidebar-toggle-btn:hover {
    color: white;
}

.side-nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0 1rem;
}

.side-nav-link {
    width: 100%;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.75);
    font-size: 1rem;
    text-align: right;
    padding: 1rem 1.25rem;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Tajawal', sans-serif;
    font-weight: 500;
    position: relative;
    border: 1px solid transparent;
}

.side-nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 0;
    background: linear-gradient(180deg, var(--accent-color), var(--accent-light));
    border-radius: 0 4px 4px 0;
    transition: height 0.3s ease;
}

.side-nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    transform: translateX(6px);
    border-color: rgba(255, 255, 255, 0.1);
    padding-left: 1.5rem;
}

.side-nav-link:hover::before {
    height: 60%;
}

.side-nav-link.active {
    background: linear-gradient(135deg, rgba(212, 161, 15, 0.25) 0%, rgba(249, 192, 101, 0.15) 100%);
    color: var(--accent-light);
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(212, 161, 15, 0.25), inset 0 0 0 1px rgba(212, 161, 15, 0.3);
    transform: translateX(8px);
    padding-left: 1.5rem;
}

.side-nav-link.active::before {
    height: 70%;
    box-shadow: 0 0 10px rgba(212, 161, 15, 0.5);
}

/* Main Panel */
.main-panel {
    flex: 1;
    padding: 2rem;
    width: 100%;
    min-width: 0;
}

/* Sub-Tab Bar */
.sub-tab-wrapper {
    display: flex;
    align-items: center;
    gap: 0;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    border-bottom: 2px solid rgba(25, 14, 102, 0.08);
    padding: 0.5rem 1rem;
    position: fixed;
    top: var(--navbar-height);
    right: var(--sidebar-width);
    left: 0;
    width: calc(100% - var(--sidebar-width));
    z-index: 998;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.sub-tab-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    background: transparent;
    border: none;
    padding: 0;
    overflow-x: auto;
    align-items: center;
    flex-shrink: 0;
}

.sub-tab {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
    font-family: 'Tajawal', sans-serif;
    white-space: nowrap;
    position: relative;
}

.sub-tab::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: 50%;
    transform: translateX(50%);
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-light));
    border-radius: 3px 3px 0 0;
    transition: width 0.3s ease;
}

.sub-tab:hover {
    color: var(--primary-color);
    background: rgba(25, 14, 102, 0.05);
}

.sub-tab:hover::before {
    width: 60%;
}

.sub-tab.active {
    background: linear-gradient(135deg, rgba(212, 161, 15, 0.1) 0%, rgba(249, 192, 101, 0.05) 100%);
    color: var(--primary-color);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(212, 161, 15, 0.15);
}

.sub-tab.active::before {
    width: 80%;
    box-shadow: 0 0 8px rgba(212, 161, 15, 0.4);
}

.builder-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.builder-toolbar input {
    max-width: 300px;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: 'Tajawal', sans-serif;
}

.builder-toolbar input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(25, 14, 102, 0.1);
}

.builder-toolbar button {
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
}

/* Date Filter Bar */
.page-tabs-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-light);
    padding: 0.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.page-tabs {
    display: flex;
    gap: 0.25rem;
}

.page-tab {
    padding: 0.4rem 1rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    white-space: nowrap;
}

.page-tab:hover {
    background: rgba(25, 14, 102, 0.08);
    color: var(--primary-color);
}

.page-tab.active {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.page-tab .delete-page {
    display: none;
    margin-right: 0.5rem;
    font-size: 0.75rem;
}

.page-tab:hover .delete-page {
    display: inline;
}

.page-tab .edit-page {
    display: none;
    margin-right: 0.25rem;
    font-size: 0.7rem;
    cursor: pointer;
    opacity: 0.7;
}

.page-tab:hover .edit-page {
    display: inline;
}

.btn-add-page {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-add-page:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.toolbar-spacer {
    flex: 1;
}

/* Slug Input */
.slug-input-container {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--bg-light);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.slug-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.slug-input {
    width: 150px;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    border: none;
    background: transparent;
}

.slug-input:focus {
    outline: none;
}

.btn-copy-slug {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem;
    border-radius: 4px;
}

.btn-copy-slug:hover {
    background: rgba(25, 14, 102, 0.1);
}

/* Date Filter Bar */
.date-filter-bar {
    display: flex;
    align-items: center;
    margin-inline-start: auto;
    flex-shrink: 0;
    border-inline-start: 1px solid rgba(25, 14, 102, 0.12);
    padding-inline-start: 0.75rem;
}

.date-filter-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.date-filter-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
}

.date-filter-inputs {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.date-input {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: 'Tajawal', sans-serif;
    background: white;
    color: var(--text-primary);
    min-width: 110px;
    transition: var(--transition);
}

.date-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(25, 14, 102, 0.1);
}

.date-separator {
    color: var(--text-secondary);
    font-size: 0.7rem;
}

.date-presets {
    display: flex;
    gap: 0.25rem;
}

.date-preset-btn {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: 'Tajawal', sans-serif;
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.date-preset-btn:hover {
    background: #f3f4f6;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.date-preset-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.date-filter-actions {
    display: flex;
    gap: 0.25rem;
}

.btn-apply-filter {
    padding: 0.3rem 0.6rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-apply-filter:hover {
    background: var(--primary-light);
}

.btn-clear-filter {
    padding: 0.3rem 0.5rem;
    background: white;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.7rem;
    font-family: 'Tajawal', sans-serif;
    cursor: pointer;
    transition: var(--transition);
}

.btn-clear-filter:hover {
    background: #f3f4f6;
    color: var(--text-primary);
}

/* Views */
.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 20px;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h2 {
    font-size: 2rem;
    color: var(--primary-color);
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
}

.report-date {
    color: var(--accent-color);
    font-size: 0.875rem;
    font-weight: 600;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.kpi-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: var(--transition);
    border-left: 5px solid var(--primary-color);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(25, 14, 102, 0.02) 0%, rgba(212, 161, 15, 0.02) 100%);
    pointer-events: none;
}

.kpi-card.animated:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 24px rgba(25, 14, 102, 0.15);
}

.kpi-icon {
    font-size: 3.5rem;
    opacity: 0.9;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.kpi-content {
    flex: 1;
}

.kpi-content h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.kpi-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Cairo', sans-serif;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.kpi-trend {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.kpi-trend.positive {
    color: var(--success-color);
}

.kpi-trend.negative {
    color: var(--danger-color);
}

/* Charts */
.dashboard-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

.chart-card h3 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
}

.chart-container {
    height: 300px;
    position: relative;
}

/* KPI Chart Integration */
.span-2-col {
    grid-column: span 2;
}

@media (max-width: 992px) {
    .span-2-col {
        grid-column: span 1;
    }
}

.kpi-chart-content-horizontal {
    width: 100%;
    height: 120px;
    /* Match typical KPI card height */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Quick Stats */
.quick-stats {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

.quick-stats h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
}

.stats-grid-small {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
    border-radius: 8px;
    border-left: 3px solid var(--accent-color);
    transition: var(--transition);
}

.stat-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

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

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Cairo', sans-serif;
}

/* Buttons */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Tajawal', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(25, 14, 102, 0.3);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

/* Form Controls */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Tajawal', sans-serif;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(25, 14, 102, 0.1);
}

/* Reports Grid */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.report-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    cursor: pointer;
    border: 2px solid transparent;
    position: relative;
}

.report-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-color);
}

.report-actions {
    position: absolute;
    top: 1rem;
    left: 1rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: var(--transition);
}

.report-card:hover .report-actions {
    opacity: 1;
}

.action-btn {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.action-btn:hover {
    background: var(--bg-light);
    transform: scale(1.1);
}

.action-btn.delete:hover {
    background: var(--danger-light);
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.action-btn.edit:hover {
    background: var(--warning-light);
    color: var(--warning-color);
    border-color: var(--warning-color);
}

/* Data Sources Grid */
.data-sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.data-source-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    border-top: 4px solid var(--accent-color);
}

.data-source-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Report Builder */
.builder-container {
    display: flex;
    gap: 0;
    min-height: calc(100vh - var(--navbar-height) - var(--sub-tab-bar-height) - 4rem);
    height: calc(100vh - var(--navbar-height) - 0.5rem);
    position: relative;
    overflow: hidden;
    /* Let wrapper handle scrolling */
}

.builder-container.palette-collapsed {
    gap: 0;
}

.widget-palette {
    width: 280px;
    background: white;
    padding: 1.5rem;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    overflow-y: auto;
    transition: all 0.3s ease;
    border-left: 1px solid var(--border-color);
    z-index: 10;
}

.builder-container.palette-collapsed .widget-palette {
    width: 0;
    padding: 0;
    opacity: 0;
}

.palette-toggle-btn {
    position: absolute;
    right: 0;
    /* Start at right edge */
    top: 50%;
    transform: translateY(-50%);
    z-index: 200;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: right 0.3s ease, transform 0.3s;
}

/* Button position when palette is collapsed - stay at right edge */
.palette-toggle-btn.collapsed {
    right: 0;
    transform: translateY(-50%) rotate(180deg);
}

.widget-palette h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-family: 'Cairo', sans-serif;
}

.widget-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.widget-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    cursor: grab;
    transition: var(--transition);
    font-size: 0.9rem;
}

.widget-item:hover {
    border-color: var(--primary-color);
    background: rgba(25, 14, 102, 0.05);
    transform: translateX(4px);
}

.widget-item:active {
    cursor: grabbing;
}

.widget-icon {
    font-size: 1.5rem;
}

.canvas-wrapper {
    flex: 1;
    overflow: auto;
    padding: 3rem;
    background-color: #f1f5f9;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.builder-canvas {
    flex: none;
    /* Don't stretch */
    width: 1000px;
    /* Default width */
    background: white;
    border-radius: 2px;
    /* More like paper */
    padding: 2rem;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
    /* Better shadow */
    min-height: 800px;
    height: auto;
    border: 1px solid var(--border-color);
    /* Subtle border */
    position: relative;
    /* Margin auto handled by wrapper justifies-content: center */
}

.canvas-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-secondary);
}

.placeholder-icon {
    font-size: 4rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.canvas-placeholder h3 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}



/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.settings-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

.settings-card h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-family: 'Cairo', sans-serif;
}

.setting-item {
    margin-bottom: 1rem;
}

.setting-item label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    z-index: 2001;
    box-shadow: var(--shadow-xl);
}

.modal-content.modal-lg {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 2px solid #f3f4f6;
}

.modal-header h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
}

.close-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.modal-body {
    padding: 2rem;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    margin-bottom: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(25, 14, 102, 0.02);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-area h4 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-area p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Footer */
.footer {
    background: linear-gradient(180deg, #100a3c 0%, #0f0833 100%);
    color: rgba(255, 255, 255, 0.7);
    padding: 2rem 0 1rem;
    margin-top: auto;
    border-top: 4px solid var(--accent-color);
    padding-right: var(--sidebar-width);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.footer-logo {
    font-size: 2rem;
}

.footer-title {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Cairo', sans-serif;
}

.footer-subtitle {
    color: var(--accent-color);
    font-size: 0.85rem;
}

.footer-version {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--success-color);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
        padding: 0.875rem 16px;
    }

    .app-shell {
        flex-direction: column;
        padding-right: 0;
    }

    .side-pane {
        position: relative;
        width: 100%;
        height: auto;
        border-radius: 16px;
        margin-bottom: 1.5rem;
        padding: 1.5rem 0;
        border-right: none;
        border-top: 3px solid rgba(212, 161, 15, 0.2);
    }

    .main-panel {
        padding: 1rem;
        width: 100%;
    }

    .sub-tab-wrapper {
        right: 0;
        width: 100%;
        flex-wrap: wrap;
    }

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

    .dashboard-charts {
        grid-template-columns: 1fr;
    }

    .builder-container {
        flex-direction: column;
        height: auto;
    }

    .widget-palette,
    .properties-panel {
        width: 100%;
    }

    .footer {
        padding-right: 0;
    }
}

/* ==========================================
   WIDGET CONFIG MODAL - EXTENDED STYLES
   ========================================== */

/* Extra Large Modal */
.modal-content.modal-xl {
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.modal-tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
}

.modal-tab:hover {
    color: var(--primary-color);
    background: var(--bg-light);
}

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

/* Modal Tab Content */
.modal-tab-content {
    display: none;
}

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

/* Form Rows (Multi-column) */
.form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Style Sections */
.style-section {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.style-section h4 {
    margin: 0 0 1rem 0;
    font-size: 0.95rem;
    color: var(--primary-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Form Controls */
.form-control-color {
    width: 60px;
    height: 36px;
    padding: 2px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    background: white;
}

.form-control-color:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-control-range {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    appearance: none;
    background: linear-gradient(to right, var(--border-color), var(--primary-color));
}

.form-control-range::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Checkbox Labels */
.style-section label input[type="checkbox"] {
    margin-left: 0.5rem;
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

/* Small Button */
.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-sm:hover {
    background: var(--border-color);
}

/* Widget hover actions */
.canvas-widget:hover .widget-actions {
    opacity: 1 !important;
}

/* Hide widget title when chart has its own title */
.canvas-widget.hide-header-title .widget-title {
    display: none;
}

/* Widget Resize Handles */
.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    border: 1px solid var(--primary-color);
    border-radius: 50%;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s;
}

.canvas-widget:hover .resize-handle,
.canvas-widget.selected .resize-handle {
    opacity: 1;
}

.resize-handle.nw {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}

.resize-handle.ne {
    top: -5px;
    right: -5px;
    cursor: ne-resize;
}

.resize-handle.sw {
    bottom: -5px;
    left: -5px;
    cursor: sw-resize;
}

.resize-handle.se {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

.resize-handle.n {
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.resize-handle.s {
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.resize-handle.w {
    top: 50%;
    left: -5px;
    transform: translateY(-50%);
    cursor: w-resize;
}

.resize-handle.e {
    top: 50%;
    right: -5px;
    transform: translateY(-50%);
    cursor: e-resize;
}

/* Quill RTL Fixes for Text Widget */
.ql-editor {
    direction: rtl;
    text-align: right;
}

.ql-editor ol,
.ql-editor ul {
    padding-left: 0 !important;
    padding-right: 2em !important;
}

.ql-editor li {
    text-align: right;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(25, 14, 102, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    position: relative;
    z-index: 10;
    box-shadow: var(--shadow-xl);
    transform: translateY(20px);
    transition: var(--transition);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-content.modal-lg {
    max-width: 900px;
}

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

.modal-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-family: 'Cairo', sans-serif;
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.close-btn:hover {
    background: var(--bg-light);
    color: var(--danger-color);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Preview Table */
.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.preview-table th {
    background: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: right;
    font-weight: 500;
    white-space: nowrap;
}

.preview-table th:first-child {
    border-top-right-radius: 8px;
}

.preview-table th:last-child {
    border-top-left-radius: 8px;
}

.preview-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

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

.preview-table tr:hover td {
    background: var(--bg-light);
}

/* Refined Buttons */
.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-weight: 500;
    transition: var(--transition);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

.btn-danger-outline:hover {
    background: var(--danger-light);
}

.source-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}