/* ====== DASHBOARD THEME (Modern Dark) ====== */
:root {
    --bg-app: #09090b;
    /* Very dark base */
    --bg-panel: #18181b;
    /* Card background */
    --bg-sidebar: #101012;
    /* Sidebar background */

    --border: #27272a;
    /* Subtle border */
    --border-hover: #3f3f46;

    --brand: #8b5cf6;
    /* Violet Primary */
    --brand-hover: #7c3aed;
    --brand-glow: rgba(139, 92, 246, 0.4);

    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;

    --font-main: 'Inter', system-ui, -apple-system, sans-serif;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* Reset & Base */
body {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: var(--font-main);
    -webkit-font-smoothing: antialiased;
    margin: 0;
    height: 100vh;
    overflow: hidden;
    /* App-like feel */
}

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

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #52525b;
}

/* ====== APP LAYOUT (Sidebar + Content) ====== */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

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

.sidebar-header {
    margin-bottom: 40px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
}

.logo-dot {
    width: 10px;
    height: 10px;
    background: var(--brand);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--brand-glow);
}

.user-role {
    font-size: 12px;
    color: var(--brand);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    background: rgba(139, 92, 246, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 32px;
    /* Space between groups */
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #52525b;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 8px;
    padding-left: 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.nav-item .icon {
    font-size: 16px;
    min-width: 20px;
}

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

.nav-item.active {
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.15), transparent);
    color: var(--brand);
    border-left: 3px solid var(--brand);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.nav-item.is-danger:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.nav-item.is-link:hover {
    color: white;
}

/* --- CONTENT AREA --- */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 40px 48px;
    position: relative;
    background-image:
        radial-gradient(circle at top right, rgba(139, 92, 246, 0.05), transparent 400px),
        radial-gradient(circle at bottom left, rgba(139, 92, 246, 0.03), transparent 400px);
}

/* Use JS to show/hide views with fade */
.view-section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view-section.active {
    display: block;
}

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

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

.view-header {
    margin-bottom: 32px;
}

.view-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: white;
}

.view-header .subtitle {
    color: var(--text-muted);
    font-size: 16px;
}

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

/* Cards */
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: white;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: linear-gradient(145deg, var(--bg-panel), #202025);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.stat-card .label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    color: white;
    margin-top: 8px;
}

/* Forms */
.form-label {
    font-size: 13px;
    font-weight: 500;
    color: #d4d4d8;
    margin-bottom: 6px;
}

.form-control,
.form-select {
    background: #09090b;
    border: 1px solid var(--border);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.form-control:focus,
.form-select:focus {
    background: #09090b;
    border-color: var(--brand);
    color: white;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.form-text {
    color: #71717a;
    font-size: 12px;
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-brand {
    background: linear-gradient(135deg, var(--brand), var(--brand-600));
    color: white;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.btn-brand:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    color: white;
}

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

.btn-outline-brand:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

/* Tables */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-muted);
    margin-bottom: 0;
}

.table thead th {
    background: #202025;
    color: #e4e4e7;
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
}

.table tbody td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: #d4d4d8;
}

.table-hover tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* ====== DESIGNER LAYOUT ====== */
.designer-layout {
    display: flex;
    height: 80vh;
    /* Fixed height within modal */
    min-height: 600px;
}

.designer-sidebar {
    width: 320px;
    border-right: 1px solid var(--border);
    background: var(--bg-panel);
    overflow-y: auto;
}

.designer-preview {
    flex: 1;
    background: #000;
}

.glass-panel {
    background: #18181b !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

/* Helper */
.d-none {
    display: none !important;
}

.scrollable {
    overflow-y: auto;
}

.bg-darker {
    background: #09090b;
}

/* ====== TOASTS ====== */
#toast-container {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast-item {
    background: rgba(24, 24, 27, 0.95);
    border: 1px solid var(--border);
    border-left: 4px solid var(--brand);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    pointer-events: auto;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(12px);
}

.toast-item.error {
    border-left-color: #ef4444;
}

.toast-item.success {
    border-left-color: #10b981;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

/* ====== SECRETS (Webhooks) ====== */
.secret-mask {
    font-family: monospace;
    color: var(--text-muted);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    user-select: none;
}

.secret-mask:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.secret-mask::after {
    content: " (Click to copy)";
    font-size: 10px;
    opacity: 0.5;
}

/* ====== MODAL GLITCH FIXES ====== */
.modal-dialog {
    max-width: 600px;
    /* Default width fix */
}

.modal-xl {
    max-width: 1140px;
}

.modal-xxl {
    max-width: 95vw;
}

.glass-panel {
    border-radius: var(--radius-lg);
    overflow: hidden;
    /* Fixes squashed feeling */
}

/* Ensure the grid in designer takes available space */
.designer-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 80vh;
}

.designer-sidebar {
    width: auto;
    /* Let grid handle it */
}

/* ====== PREVIEW SCALING ====== */
.preview-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #000;
    width: 100%;
}

.preview-canvas {
    width: 1280px;
    height: 720px;
    background: #000;
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: top left;
}