/* ==========================================================================
   DASHBOARD VARIABLES & RESET
   ========================================================================== */
:root {
    --primary: #df2d12;
    --primary-hover: #b9250f;
    --sidebar-bg: #f8fafc;
    --sidebar-hover: #e2e8f0;
    --sidebar-text: #475569;
    --sidebar-active: #df2d12;
    --canvas-bg: #ffffff;
    --card-bg: #ffffff;
    --text-main: #000000;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    letter-spacing: -0.01em;
}

body {
    background-color: var(--canvas-bg);
    color: var(--text-main);
    overflow: hidden;
    /* Prevents full page scroll, only main-content will scroll */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   LAYOUT GRID
   ========================================================================== */
.dashboard-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 24px;
    color: white;
    border-bottom: 1px solid var(--sidebar-hover);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 24px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.nav-item:hover {
    background-color: var(--sidebar-hover);
    color: white;
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--sidebar-hover);
}

.logout-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--sidebar-hover);
    color: var(--sidebar-text);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.logout-btn:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: #ffffff;
}

/* ==========================================================================
   MAIN CONTENT & TOPBAR
   ========================================================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.main-content,
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.main-content::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.main-content::-webkit-scrollbar-track,
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.main-content::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
}

.main-content:hover::-webkit-scrollbar-thumb,
.sidebar-nav:hover::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    /* Subtle on hover only */
}

[data-theme="dark"] .main-content:hover::-webkit-scrollbar-thumb,
[data-theme="dark"] .sidebar-nav:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--canvas-bg);
}

.greeting h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.greeting p {
    color: var(--text-muted);
    font-size: 13px;
}

.profile-badge {
    cursor: pointer;
}

.avatar {
    width: 40px;
    height: 40px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.2);
}

/* ==========================================================================
   DASHBOARD CANVAS & EMPTY STATE
   ========================================================================== */
.dashboard-canvas {
    padding: 0 48px 48px 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 48px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.icon-wrapper {
    width: 64px;
    height: 64px;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    color: white;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 24px auto;
    box-shadow: 0 10px 15px -3px rgba(220, 39, 67, 0.3);
}

.empty-state-card h2 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 12px;
}

.empty-state-card p {
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 13px;
    line-height: 1.5;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.secure-badge {
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
}

/* ==========================================================================
   MODALS & ONBOARDING
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.modal-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 90%;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

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

.onboarding-step h4 {
    color: #1e293b;
    font-size: 15px;
    font-weight: 600;
}

.onboarding-step p {
    line-height: 1.5;
}

/* ==========================================================================
   ENHANCED AUTOMATION UI (GLASSMORPHISM CARDS)
   ========================================================================== */
.rule-row-card {
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.3), inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-theme="light"] .rule-row-card {
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05), inset 0 1px 0 0 rgba(255, 255, 255, 0.8);
}

.rule-row-card:hover {
    transform: translateY(-3px) scale(1.002);
    box-shadow: 0 20px 40px -10px rgba(109, 94, 247, 0.25), inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
    z-index: 10;
}

[data-theme="light"] .rule-row-card:hover {
    box-shadow: 0 20px 40px -10px rgba(109, 94, 247, 0.15), inset 0 1px 0 0 rgba(255, 255, 255, 0.9);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-15px) scale(0.98);
    }

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

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

.rule-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rule-badge.dm {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(37, 99, 235, 0.2) 100%);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.25);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .rule-badge.dm {
    box-shadow: none;
    color: #60a5fa;
}

.rule-badge.cm {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.12) 0%, rgba(22, 163, 74, 0.2) 100%);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.25);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .rule-badge.cm {
    box-shadow: none;
    color: #4ade80;
}

.rule-delete-epic {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(241, 245, 249, 0.8);
    color: #94a3b8;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.rule-delete-epic:hover {
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid #fecaca;
    transform: rotate(6deg) scale(1.08);
}

[data-theme="dark"] .rule-delete-epic {
    background: rgba(30, 41, 59, 0.8);
    color: #64748b;
}

[data-theme="dark"] .rule-delete-epic:hover {
    background: rgba(127, 29, 29, 0.4);
    border-color: rgba(153, 27, 27, 0.6);
}

.premium-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.premium-input-wrap label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.premium-input-box {
    position: relative;
    display: flex;
    align-items: center;
}

.premium-input-icon {
    position: absolute;
    left: 14px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: color 0.2s;
}

.premium-input-box input {
    width: 100%;
    padding: 14px 14px 14px 44px !important;
    background: var(--bg-elevated, #f8fafc);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 400;
    color: var(--text-main);
    transition: all 0.25s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .premium-input-box input {
    background: rgba(15, 23, 42, 0.5);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.premium-input-box input:focus {
    outline: none;
    background: var(--canvas-bg, #ffffff);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(109, 94, 247, 0.15), inset 0 1px 2px rgba(0, 0, 0, 0.01);
}

.premium-input-box input:focus+.premium-input-icon {
    color: var(--primary);
}

.responsive-grid-premium {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .responsive-grid-premium {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

.premium-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--border-color);
}

.premium-footer span {
    color: var(--text-main);
}

/* Hyper Modern Toggle */
.toggle-neo {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-neo input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-neo-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s cubic-bezier(0.4, 0.0, 0.2, 1);
    border-radius: 34px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .toggle-neo-slider {
    background-color: #334155;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.toggle-neo-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s cubic-bezier(0.4, 0.0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.toggle-neo input:checked+.toggle-neo-slider {
    background-color: var(--primary);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 12px rgba(109, 94, 247, 0.4);
}

.toggle-neo input:checked+.toggle-neo-slider:before {
    transform: translateX(24px);
}