/* NOURGRID INNOVATIVE DESIGN SYSTEM (v1.0) */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* --- BRAND IDENTITY (New Spec) --- */
    --brand-primary: #F4C430;
    /* Saffron Yellow */
    --brand-primary-dim: #D4A010;
    /* Darker for hover */
    --brand-accent: #10B981;
    /* Success Green */
    --brand-warning: #F59E0B;
    /* Warning Orange */
    --brand-danger: #EF4444;
    /* Danger Red */

    /* --- DARK THEME (Spec Exact) --- */
    --bg-app: #0A0A0A;
    /* Almost Black */
    --bg-panel: #1A1A1A;
    /* Dark Gray Cards */
    --bg-surface: #252525;
    /* Slightly lighter controls */
    --bg-surface-2: #141418;
    /* Canvas background */

    /* --- GLASSMORPHISM VARS --- */
    --glass-bg: rgba(30, 30, 36, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(20px);

    /* --- TEXT & BORDERS --- */
    --text-main: #FFFFFF;
    --text-muted: #8F9098;
    --border-subtle: rgba(255, 255, 255, 0.05);

    /* --- DIMENSIONS --- */
    --sidebar-width: 80px;
    /* Compact sidebar */
    --header-height: 80px;

    /* --- RADII (Creative Roundness) --- */
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 32px;
    --radius-pill: 999px;

    /* --- SHADOW SYSTEM (Depth Layers) --- */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(255, 209, 0, 0.3);
    --shadow-glow-strong: 0 0 30px rgba(255, 209, 0, 0.5);
}

/* --- LIGHT MODE OVERRIDES --- */
[data-theme="light"] {
    --bg-app: #F5F5F7;
    /* Light Grey Apple-ish */
    --bg-panel: #FFFFFF;
    --bg-surface: #F0F0F2;
    --bg-surface-2: #E5E5E7;

    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.05);

    --text-main: #1D1D1F;
    --text-muted: #86868B;
    --border-subtle: rgba(0, 0, 0, 0.08);
}

/* --- ADVANCED ANIMATIONS --- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes pulse {

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

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(255, 209, 0, 0.3);
    }

    50% {
        box-shadow: 0 0 30px rgba(255, 209, 0, 0.6);
    }
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }

    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* --- RESET & TYPOGRAPHY --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 16px;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

@media (min-width: 1400px) {
    body {
        font-size: 18px;
        /* Slightly larger on big screens */
    }
}

a {
    text-decoration: none;
    color: inherit;
    transition: 0.2s;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

/* --- COMPONENT: BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.8rem 1.75rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: none;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--brand-primary);
    color: #000000;
    box-shadow: 0 4px 15px rgba(255, 209, 0, 0.25);
}

.btn-primary:hover {
    background: var(--brand-primary-dim);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(255, 209, 0, 0.4);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 10px rgba(255, 209, 0, 0.3);
}

.btn-glass {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    backdrop-filter: blur(10px);
}

.btn-glass:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-glass:active {
    transform: translateY(0) scale(0.98);
}

/* Loading State */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

/* --- COMPONENT: CARDS & CONTAINERS --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
}

.glass-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.1),
            transparent);
    opacity: 0.5;
}

.glass-panel:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Disable lift hover on glass panels inside grids (device cards, stats) to prevent flickering */
.grid-layout > .glass-panel:hover,
.grid-layout .glass-panel:hover {
    transform: none;
}

/* Animated Glass Panel */
.glass-panel.animated {
    animation: slideUp 0.6s ease-out;
}

/* --- LAYOUT: MAIN SHELL --- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* --- SIDEBAR (Floating Dock Style) --- */
.sidebar {
    height: 100vh;
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 0;
    background: var(--bg-panel);
    z-index: 100;
    position: sticky;
    top: 0;
    animation: fadeIn 0.4s ease-out;
}

.brand-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 3rem;
    filter: drop-shadow(0 0 10px rgba(255, 209, 0, 0.2));
    transition: transform 0.3s ease;
}

.brand-icon:hover {
    transform: scale(1.1) rotate(5deg);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    align-items: center;
}

.nav-link {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.5rem;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--brand-primary);
    border-radius: 16px;
    transform: scale(0);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: -1;
}

.nav-link:hover::before,
.nav-link.active::before {
    transform: scale(1);
}

.nav-link:hover,
.nav-link.active {
    color: #000;
    box-shadow: var(--shadow-glow);
    transform: scale(1.15);
}

.nav-link:active {
    transform: scale(1.05);
}

/* --- MAIN CONTENT AREA --- */
.main-view {
    padding: 3rem;
    /* Increased padding for more space */
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    overflow-y: auto;
    height: 100vh;
}

/* --- TOP HEADER --- */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-pill {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 400px;
    max-width: 100%;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.search-pill:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(244, 196, 48, 0.1);
    background: var(--bg-panel);
}

.search-pill ion-icon {
    transition: color 0.3s ease;
}

.search-pill:focus-within ion-icon {
    color: var(--brand-primary);
}

.search-pill input {
    background: transparent;
    border: none;
    color: var(--text-main);
    width: 100%;
    font-size: 0.95rem;
}

.search-pill input::placeholder {
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.search-pill input:focus::placeholder {
    color: transparent;
}

/* --- GRID SYSTEM --- */
.grid-layout {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 2rem;
    /* Increased gap */
    width: 100%;
}

.col-12 {
    grid-column: span 12;
}

.col-8 {
    grid-column: span 8;
}

.col-6 {
    grid-column: span 6;
}

.col-4 {
    grid-column: span 4;
}

/* Responsive */
@media (max-width: 1200px) {

    .col-8,
    .col-6,
    .col-4 {
        grid-column: span 12;
    }
}

/* --- UTILITIES --- */
.hidden {
    display: none !important;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.text-h1 {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -1px;
}

.text-h2 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.text-label {
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

/* --- MIRO-STYLE CANVAS INTERFACE --- */
.canvas-stage {
    position: relative;
    width: 100%;
    height: 100%;
    background: #0a0a0a;
    background-image:
        linear-gradient(rgba(16, 185, 129, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(16, 185, 129, 0.08) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: grab;
    user-select: none;
    border: 1px solid var(--border-subtle);
}

.canvas-stage:active {
    cursor: grabbing;
}

.canvas-viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
}

.canvas-layer-edges {
    position: absolute;
    top: 0;
    left: 0;
    width: 5000px;
    height: 5000px;
    z-index: 20;
    /* Between machines and cards */
    overflow: visible;
    pointer-events: none;
}

.canvas-layer-nodes {
    position: absolute;
    top: 0;
    left: 0;
    width: 5000px;
    height: 5000px;
    z-index: 10;
    /* Base layer for machines */
    pointer-events: none;
}

/* MIRO-STYLE VERTICAL TOOLBAR */
.canvas-toolbar-vertical {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(25, 25, 30, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 900;
}

.canvas-toolbar-vertical .tool-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #888;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.canvas-toolbar-vertical .tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.canvas-toolbar-vertical .tool-btn.active {
    background: var(--brand-primary);
    color: #000;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

.canvas-toolbar-vertical .tool-divider {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

.canvas-toolbar-vertical .tool-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 60px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
}

.canvas-toolbar-vertical .tool-btn:hover::after {
    opacity: 1;
}

.canvas-controls-top {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 900;
}

.canvas-controls-top .btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(25, 25, 30, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
}

.canvas-node {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: move;
    transition: box-shadow 0.2s, outline 0.2s;
    pointer-events: auto;
}

.canvas-node.selected {
    outline: 2px solid var(--brand-primary);
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.4);
    z-index: 100;
}

.node-photo-wrapper {
    position: relative;
    padding: 0;
    background: transparent;
    border: 2px solid var(--border-subtle);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    z-index: 10;
}

.node-photo-wrapper img {
    display: block;
    pointer-events: none;
    user-select: none;
}

.photo-anchor {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--brand-accent);
    border: 2px solid #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: crosshair;
    z-index: 50;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s;
}

.photo-anchor:hover {
    transform: translate(-50%, -50%) scale(1.5);
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid var(--brand-primary);
    border-radius: 50%;
    z-index: 200;
    pointer-events: auto;
    /* Ensure they capture clicks */
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.resize-handle:hover {
    background: var(--brand-primary);
    transform: scale(1.2);
}

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

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

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

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

.node-card {
    min-width: 180px;
    background: #2a2a32;
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    display: flex;
    overflow: hidden;
    z-index: 30;
    /* Always on top of lines */
}

.canvas-lasso {
    position: absolute;
    border: 1px solid var(--brand-primary);
    background: rgba(16, 185, 129, 0.1);
    pointer-events: none;
    z-index: 1000;
}

.card-green {
    border-left-color: #10B981;
}

.card-blue {
    border-left-color: #0EA5E9;
}

.card-yellow {
    border-left-color: #F59E0B;
}

.card-red {
    border-left-color: #EF4444;
}

.card-purple {
    border-left-color: #A855F7;
}

.card-icon {
    width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    font-size: 1.5rem;
    color: #fff;
}

.card-green .card-icon {
    color: #10B981;
}

.card-blue .card-icon {
    color: #0EA5E9;
}

.card-yellow .card-icon {
    color: #F59E0B;
}

.card-red .card-icon {
    color: #EF4444;
}

.card-purple .card-icon {
    color: #A855F7;
}

.card-content {
    padding: 0.8rem 1rem;
    flex: 1;
}

.card-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.1;
}

.context-menu {
    position: fixed;
    top: 0;
    left: 0;
    background: rgba(20, 20, 25, 0.98);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 0.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: none;
    flex-direction: column;
    min-width: 220px;
    max-height: 70vh;
    overflow-y: auto;
}

.context-menu.active {
    display: flex;
}

.menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 0.9rem;
    color: #ccc;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.menu-item.danger {
    color: #EF4444;
}

.menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.edge-path {
    fill: none;
    stroke: var(--brand-primary);
    stroke-width: 3px;
    stroke-linecap: round;
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.5));
    transition: stroke 0.2s;
    pointer-events: stroke;
    cursor: pointer;
}

.edge-flow {
    fill: none;
    stroke: currentColor;
    stroke-width: 4px;
    stroke-linecap: round;
    stroke-dasharray: 0 30;
    animation: flow 1.5s linear infinite;
    opacity: 0.6;
    pointer-events: none;
}

@keyframes flow {
    to {
        stroke-dashoffset: -30;
    }
}

.edge-temp {
    stroke: var(--brand-primary);
    stroke-width: 2px;
    stroke-dasharray: 5 5;
    fill: none;
    pointer-events: none;
    display: none;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #888;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.status-row.active {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-weight: 600;
}

.status-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #444;
    transition: all 0.3s ease;
}

.status-row.active .status-led {
    background: #10B981;
    animation: pulse 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

/* --- LOADING & SKELETON SCREENS --- */
.skeleton {
    background: linear-gradient(90deg,
            var(--bg-surface) 0%,
            rgba(255, 255, 255, 0.05) 50%,
            var(--bg-surface) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-card {
    height: 200px;
}

/* --- NOTIFICATION BADGE --- */
.notification-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 18px;
    height: 18px;
    background: #EF4444;
    border-radius: 999px;
    animation: pulse 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    pointer-events: none;
}

.notification-badge.hidden {
    display: none !important;
}

/* --- NOTIFICATION DROPDOWN PANEL --- */
.notification-panel {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 380px;
    max-height: 480px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl), 0 0 60px rgba(0,0,0,0.3);
    z-index: 2000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: notifSlideIn 0.25s ease-out;
}

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

@keyframes notifSlideIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.notif-header h4 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.notif-mark-read {
    font-size: 0.75rem;
    color: var(--brand-primary);
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s;
}

.notif-mark-read:hover {
    opacity: 0.7;
}

.notif-list {
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem;
}

.notif-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.notif-item:hover {
    background: rgba(255,255,255,0.05);
}

.notif-item.unread {
    background: rgba(244, 196, 48, 0.04);
}

.notif-item.unread::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand-primary);
    box-shadow: 0 0 8px rgba(244,196,48,0.5);
}

.notif-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
}

.notif-icon.alert { background: rgba(239,68,68,0.15); color: #EF4444; }
.notif-icon.success { background: rgba(16,185,129,0.15); color: #10B981; }
.notif-icon.info { background: rgba(59,130,246,0.15); color: #3B82F6; }
.notif-icon.warning { background: rgba(245,158,11,0.15); color: #F59E0B; }

.notif-content {
    flex: 1;
    min-width: 0;
}

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

.notif-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.notif-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    gap: 0.75rem;
}

.notif-empty ion-icon {
    font-size: 2.5rem;
    opacity: 0.3;
}

.notif-footer {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
}

.notif-footer a {
    font-size: 0.8rem;
    color: var(--brand-primary);
    font-weight: 600;
}

/* --- PROFILE DROPDOWN PANEL --- */
.profile-panel {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 340px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl), 0 0 60px rgba(0,0,0,0.3);
    z-index: 2000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: notifSlideIn 0.25s ease-out;
}

.profile-panel.active {
    display: flex;
}

.profile-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
    background: linear-gradient(to bottom, rgba(244,196,48,0.05), transparent);
}

.profile-avatar-lg {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid var(--brand-primary);
    box-shadow: 0 0 20px rgba(244,196,48,0.2);
    margin-bottom: 0.75rem;
    transition: transform 0.3s;
}

.profile-avatar-lg:hover {
    transform: scale(1.08);
}

.profile-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.2rem;
}

.profile-email {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.profile-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-pill);
    background: rgba(244,196,48,0.12);
    color: var(--brand-primary);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    font-size: 0.78rem;
    color: #10B981;
}

.profile-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 8px rgba(16,185,129,0.5);
    animation: pulse 2s ease-in-out infinite;
}

.profile-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0;
    border-bottom: 1px solid var(--border-subtle);
}

.profile-stat {
    padding: 1rem;
    text-align: center;
    transition: background 0.2s;
}

.profile-stat:not(:last-child) {
    border-right: 1px solid var(--border-subtle);
}

.profile-stat:hover {
    background: rgba(255,255,255,0.03);
}

.profile-stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
}

.profile-stat-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.35rem;
}

.profile-actions {
    padding: 0.5rem;
}

.profile-action-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.2s;
}

.profile-action-item:hover {
    background: rgba(255,255,255,0.05);
}

.profile-action-item ion-icon {
    font-size: 1.25rem;
    color: var(--text-muted);
    width: 28px;
    text-align: center;
}

.profile-action-item.danger {
    color: #EF4444;
}

.profile-action-item.danger ion-icon {
    color: #EF4444;
}

.profile-action-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 0.25rem 1rem;
}

/* Overlay for closing dropdowns */
.dropdown-overlay {
    position: fixed;
    inset: 0;
    z-index: 1999;
    display: none;
}

.dropdown-overlay.active {
    display: block;
}

/* --- ENHANCED UTILITIES --- */
.fade-in {
    animation: fadeIn 0.6s ease-out;
}

.slide-up {
    animation: slideUp 0.6s ease-out;
}

.float {
    animation: float 3s ease-in-out infinite;
}

/* Staggered animations for lists */
.stagger-1 {
    animation-delay: 0.1s;
}

.stagger-2 {
    animation-delay: 0.2s;
}

.stagger-3 {
    animation-delay: 0.3s;
}

.stagger-4 {
    animation-delay: 0.4s;
}

/* --- TOOLTIP --- */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

.tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* --- PAGE TRANSITIONS --- */
.page-transition {
    animation: fadeIn 0.4s ease-out;
}

/* --- IMPROVED RESPONSIVE --- */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        padding: 1rem 0;
    }

    .brand-icon {
        width: 36px;
        height: 36px;
        margin-bottom: 2rem;
    }

    .nav-link {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .search-pill {
        width: 100%;
        max-width: 100%;
    }

    .top-header {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .hidden-mobile {
        display: none !important;
    }

    .main-view {
        padding: 1rem;
        gap: 1.5rem;
    }

    .grid-layout {
        gap: 1rem;
    }

    .glass-panel {
        padding: 1rem !important;
    }
}

/* --- ENHANCED SCROLLBAR --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-panel);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-surface);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- FOCUS STATES (Accessibility) --- */
*:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* --- RIGHT-TO-LEFT (RTL) SUPPORT FOR ARABIC --- */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .sidebar {
    border-right: none;
    border-left: 1px solid var(--border-subtle);
}

[dir="rtl"] .flex-between {
    flex-direction: row-reverse;
}

[dir="rtl"] .search-pill {
    flex-direction: row-reverse;
}

[dir="rtl"] .search-pill input {
    text-align: right;
}

[dir="rtl"] .btn {
    flex-direction: row-reverse;
}

[dir="rtl"] .user-profile-trigger {
    border-left: none !important;
    border-right: 1px solid var(--border-subtle) !important;
    padding-left: 0 !important;
    padding-right: 1rem !important;
    flex-direction: row-reverse;
}

[dir="rtl"] .user-profile-trigger .hidden-mobile {
    text-align: left !important;
}

[dir="rtl"] .text-left {
    text-align: right !important;
}

[dir="rtl"] table th, 
[dir="rtl"] table td {
    text-align: right !important;
}

[dir="rtl"] .canvas-toolbar-vertical {
    left: auto;
    right: 20px;
}

[dir="rtl"] .canvas-controls-top {
    right: auto;
    left: 1rem;
    flex-direction: row-reverse;
}

[dir="rtl"] .canvas-toolbar-vertical .tool-btn::after {
    left: auto;
    right: 60px;
}

/* --- GUIDANCE TIPS --- */
.info-tip {
    margin-top: 1rem;
    padding: 0.85rem 1.1rem;
    background: rgba(255, 200, 0, 0.08);
    border-radius: 10px;
    border: 1px solid rgba(255, 200, 0, 0.18);
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.info-tip ion-icon {
    color: #FFC800;
    vertical-align: middle;
    margin-right: 0.3rem;
    font-size: 1rem;
}

.info-tip code {
    background: rgba(0, 0, 0, 0.15);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.78rem;
}

[data-theme="light"] .info-tip code {
    background: rgba(0, 0, 0, 0.07);
}

.info-tip b, .info-tip strong {
    color: var(--text-main);
}

.info-tip details {
    margin-top: 0.5rem;
}

.info-tip details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.82rem;
}

.info-tip details[open] summary {
    margin-bottom: 0.4rem;
}

.info-tip .tip-section {
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255, 200, 0, 0.08);
}

.info-tip .tip-section:last-child {
    border-bottom: none;
}