@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    --primary: #673de6;
    --primary-hover: #5025d1;
    --primary-glow: rgba(103, 61, 230, 0.35);
    --primary-light: rgba(103, 61, 230, 0.12);
    
    --bg-page: #0b0c13;
    --bg-sidebar: #10121b;
    --bg-card: #161824;
    --bg-card-hover: #1c1e2e;
    --bg-input: #12131d;
    --bg-code: #0d0e17;

    --border: #23263b;
    --border-focus: #4b369d;
    --border-light: rgba(255, 255, 255, 0.08);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --success: #00b074;
    --success-bg: rgba(0, 176, 116, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --info: #06b6d4;
    --info-bg: rgba(6, 182, 212, 0.12);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 25px var(--primary-glow);

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

body[dir="ltr"] {
    font-family: 'Plus Jakarta Sans', 'Cairo', system-ui, sans-serif;
}

/* Links & Buttons */
a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: #8b5cf6;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition);
}

input, select, textarea {
    font-family: inherit;
    color: var(--text-main);
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
}
.btn-primary {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}
.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--text-dim);
}
.btn-danger {
    background-color: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    background-color: var(--danger);
    color: #fff;
}
.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(0, 176, 116, 0.2); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-primary { background: var(--primary-light); color: #a78bfa; border: 1px solid rgba(103, 61, 230, 0.3); }

/* Main App Shell */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Navbar */
.top-nav {
    height: 68px;
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.3rem;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
}
.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px var(--primary-glow);
}
.brand-pill {
    font-size: 0.7rem;
    background: rgba(103, 61, 230, 0.2);
    border: 1px solid var(--primary);
    color: #c4b5fd;
    padding: 2px 8px;
    border-radius: 12px;
    margin-inline-start: 4px;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}
.site-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px 12px;
}
.site-selector-wrapper select {
    background: transparent;
    border: none;
    padding: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 4px 12px 4px 6px;
}
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 0.9rem;
}
.user-info {
    display: flex;
    flex-direction: column;
    text-align: start;
    line-height: 1.2;
}
.user-name {
    font-size: 0.85rem;
    font-weight: 700;
}
.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Layout Canvas */
.main-layout {
    display: flex;
    flex: 1;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--bg-sidebar);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0.8rem;
    gap: 6px;
    flex-shrink: 0;
}
.nav-category {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    padding: 10px 14px 4px 14px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.93rem;
    cursor: pointer;
    transition: var(--transition);
}
.nav-item:hover {
    background-color: var(--bg-card);
    color: var(--text-main);
}
.nav-item.active {
    background-color: var(--primary-light);
    color: #c4b5fd;
    border-inline-start: 3px solid var(--primary);
}
.nav-item-icon {
    font-size: 1.15rem;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    background-color: var(--bg-page);
    overflow-y: auto;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Page Headers */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-title {
    font-size: 1.7rem;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}
.page-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}
.stat-card:hover {
    border-color: var(--border-focus);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}
.stat-icon.purple { background: rgba(103, 61, 230, 0.15); color: #a78bfa; }
.stat-icon.green  { background: rgba(0, 176, 116, 0.15); color: #34d399; }
.stat-icon.cyan   { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.stat-icon.amber  { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.1;
}
.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}
.stat-progress {
    height: 8px;
    background: var(--bg-input);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 1rem;
}
.stat-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #a78bfa);
    border-radius: 10px;
    transition: width 0.6s ease;
}

/* Quick Features Section */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.2rem;
    margin-bottom: 2rem;
}
.feature-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: var(--transition);
    text-align: start;
}
.feature-card:hover {
    border-color: var(--primary);
    background-color: var(--bg-card-hover);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(103, 61, 230, 0.15);
}
.feature-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.feature-icon-box {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(103, 61, 230, 0.12);
    color: #a78bfa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}
.feature-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}
.feature-desc {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.4;
    margin-bottom: 1rem;
}
.feature-link {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* File Manager Component */
.fm-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.fm-toolbar {
    background-color: #121420;
    border-bottom: 1px solid var(--border);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.fm-actions-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.fm-search {
    position: relative;
    min-width: 220px;
}
.fm-search input {
    width: 100%;
    padding-inline-start: 36px;
}
.fm-search-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    inset-inline-start: 12px;
    color: var(--text-dim);
}

.fm-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background-color: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
    font-weight: 600;
    overflow-x: auto;
}
.breadcrumb-crumb {
    color: var(--primary);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}
.breadcrumb-crumb:hover {
    background: var(--primary-light);
}
.breadcrumb-sep {
    color: var(--text-dim);
}
.breadcrumb-crumb.active {
    color: var(--text-main);
    cursor: default;
}

/* Files Table */
.fm-table-wrap {
    overflow-x: auto;
    min-height: 380px;
}
.fm-table {
    width: 100%;
    border-collapse: collapse;
    text-align: start;
    font-size: 0.92rem;
}
.fm-table th {
    padding: 12px 18px;
    background-color: #11131e;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.fm-table td {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
}
.fm-row {
    transition: var(--transition);
    cursor: pointer;
}
.fm-row:hover {
    background-color: var(--bg-card-hover);
}
.fm-item-name {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}
.fm-item-icon {
    font-size: 1.3rem;
}
.fm-row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.fm-row:hover .fm-row-actions {
    opacity: 1;
}

/* Dropzone Overlay */
.fm-dropzone {
    border: 2px dashed var(--primary);
    background: rgba(103, 61, 230, 0.08);
    border-radius: var(--radius-lg);
    padding: 3rem;
    text-align: center;
    margin: 1rem;
    cursor: pointer;
    transition: var(--transition);
}
.fm-dropzone:hover, .fm-dropzone.dragover {
    background: rgba(103, 61, 230, 0.16);
    border-color: #a78bfa;
}

/* Code Editor Window */
.code-editor-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}
.editor-window {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}
.editor-header {
    background: #131522;
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.editor-filename {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}
.editor-textarea {
    flex: 1;
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 1.2rem;
    resize: none;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

/* Database Manager Component */
.db-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
}
.db-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.db-table-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
}
.db-table-item:hover, .db-table-item.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: #c4b5fd;
}
.db-main-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sql-console {
    background: #0f101b;
    border-bottom: 1px solid var(--border);
    padding: 1.2rem;
}
.sql-textarea {
    width: 100%;
    min-height: 100px;
    background: #0a0b12;
    border: 1px solid var(--border);
    color: #a5b4fc;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    padding: 12px;
    border-radius: var(--radius-md);
    resize: vertical;
}

/* Modal Windows */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 550px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalPop {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    padding: 1.2rem 1.5rem;
    background: #121420;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}
.modal-body {
    padding: 1.5rem;
}
.modal-footer {
    padding: 1rem 1.5rem;
    background: #121420;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 24px;
    inset-inline-end: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: #181a28;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-md);
    color: #fff;
    font-size: 0.92rem;
    font-weight: 600;
    animation: slideIn 0.3s ease;
}
.toast.success { border-inline-start: 4px solid var(--success); }
.toast.error   { border-inline-start: 4px solid var(--danger); }
.toast.info    { border-inline-start: 4px solid var(--info); }
@keyframes slideIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form Groups */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 1.2rem;
}
.form-label {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 900px) {
    .sidebar {
        display: none;
    }
    .db-container {
        grid-template-columns: 1fr;
    }
    .content-area {
        padding: 1.2rem;
    }
}
