/* ========================================
   ModulairCMS Admin Stylesheet
   ======================================== */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --dark: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --text: #334155;
    --text-light: #94a3b8;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--light);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* Login Page */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-container { width: 100%; max-width: 420px; padding: 20px; }

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-icon {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 10px;
}

.login-header h1 {
    font-size: 24px;
    color: var(--dark);
    margin-bottom: 5px;
}

.login-header p {
    color: var(--text-light);
    font-size: 14px;
}

.login-form .form-group { margin-bottom: 20px; }

.login-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-light);
    font-size: 12px;
}

/* Admin Layout */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--dark);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.sidebar-header h2 i {
    color: var(--primary);
    margin-right: 8px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: none;
}

.sidebar-nav {
    padding: 10px 0;
}

.nav-section {
    padding: 15px 20px 5px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: #cbd5e1;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

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

.nav-item.active {
    background: rgba(37, 99, 235, 0.2);
    color: white;
    border-left-color: var(--primary);
}

.nav-item i {
    width: 24px;
    margin-right: 12px;
    font-size: 15px;
    text-align: center;
}

/* Main Content */
.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* Top Bar */
.admin-topbar {
    background: white;
    height: var(--topbar-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-left h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text);
    cursor: pointer;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-weight: 500;
    color: var(--text);
}

/* Content Area */
.admin-content {
    padding: 24px;
}

/* Form Elements */
input.form-control:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="hidden"]),
select.form-control,
textarea.form-control {
    width: 100%;
    padding: 10px 2px 8px;
    border: 0;
    border-bottom: 2px solid var(--border);
    border-radius: 0;
    font-size: 14px;
    color: var(--text);
    background: transparent;
    transition: border-color 0.2s;
}

input.form-control:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="hidden"]):focus,
select.form-control:focus,
textarea.form-control:focus {
    outline: none;
    border-bottom-color: var(--primary);
    box-shadow: none;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 2px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 28px;
}

input.form-control[type="color"],
input.form-control[type="file"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

input.form-control::placeholder,
textarea.form-control::placeholder {
    color: var(--text-light);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.form-group .help-text {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; color: white; }
.btn-outline { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--light); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

.btn-group { display: flex; gap: 8px; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #93c5fd; }

.alert-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--light);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--secondary);
}

.table tr:hover {
    background: #f1f5f9;
}

.table .actions {
    white-space: nowrap;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: var(--primary-light); color: var(--primary-dark); }

/* Cards */
.dashboard-card, .card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--light);
}

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

.stat-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.bg-blue { background: var(--primary); }
.bg-green { background: var(--success); }
.bg-purple { background: #8b5cf6; }
.bg-orange { background: var(--warning); }
.bg-red { background: var(--danger); }
.bg-teal { background: var(--info); }

.stat-info h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
    line-height: 1;
}

.stat-info p {
    color: var(--text-light);
    font-size: 13px;
    margin-top: 2px;
}

/* Dashboard */
.dashboard-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

/* Page Builder */
.page-builder {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 0;
    min-height: calc(100vh - var(--topbar-height) - 48px);
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.builder-sidebar {
    background: var(--light);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.builder-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.builder-elements {
    padding: 12px;
}

.builder-element {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 6px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: grab;
    transition: all 0.2s;
    font-size: 13px;
}

.builder-element:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

.builder-element i {
    width: 20px;
    color: var(--primary);
}

.builder-canvas {
    padding: 24px;
    min-height: 400px;
}

.builder-canvas-area {
    min-height: 300px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color 0.2s;
}

.builder-canvas-area.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.builder-canvas-area.empty::before {
    content: 'Sleep elementen hierheen om uw pagina op te bouwen';
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: var(--text-light);
    font-size: 16px;
}

/* Builder Blocks */
.builder-block {
    position: relative;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    cursor: grab;
}

.builder-block:hover {
    border-color: var(--primary);
}

.builder-block .block-toolbar {
    position: absolute;
    top: -12px;
    right: 8px;
    display: none;
    gap: 4px;
    background: var(--dark);
    border-radius: 4px;
    padding: 4px;
}

.builder-block:hover .block-toolbar {
    display: flex;
}

.block-toolbar button {
    background: none;
    border: none;
    color: white;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    border-radius: 3px;
}

.block-toolbar button:hover {
    background: rgba(255,255,255,0.2);
}

.builder-block [contenteditable] {
    outline: none;
    min-height: 24px;
}

.builder-block [contenteditable]:focus {
    background: var(--primary-light);
    border-radius: 4px;
    padding: 4px;
}

/* Menu Builder */
.menu-builder {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.menu-items-list {
    list-style: none;
    padding: 0;
}

.menu-item {
    padding: 12px 16px;
    margin: 6px 0;
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
}

.menu-item:hover {
    border-color: var(--primary);
}

.menu-item .item-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-item .drag-handle {
    color: var(--text-light);
    cursor: grab;
}

.menu-item .item-actions {
    display: flex;
    gap: 6px;
}

.menu-item .nested-items {
    margin-left: 30px;
    margin-top: 8px;
}

/* Pagination */
.pagination {
    margin-top: 20px;
}

.pagination ul {
    display: flex;
    list-style: none;
    gap: 4px;
}

.pagination li a {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
}

.pagination li.active a {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination li a:hover {
    background: var(--light);
}

/* Content Header */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.content-header h2 {
    font-size: 20px;
    font-weight: 600;
}

/* Text utilities */
.text-muted { color: var(--text-light); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* Grid for templates/modules listing */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.grid-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.grid-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.grid-card-image {
    height: 180px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: var(--primary);
}

.grid-card-body {
    padding: 16px;
}

.grid-card-body h4 {
    font-size: 16px;
    margin-bottom: 6px;
}

.grid-card-body p {
    color: var(--text-light);
    font-size: 13px;
    margin-bottom: 12px;
}

.grid-card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Settings tabs */
.settings-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
}

.settings-tab {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.settings-tab:hover {
    color: var(--primary);
}

.settings-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

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

/* Image upload area */
.image-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.image-upload-area:hover {
    border-color: var(--primary);
}

.image-upload-area i {
    font-size: 36px;
    color: var(--text-light);
    margin-bottom: 10px;
}

.image-preview {
    max-width: 200px;
    border-radius: var(--radius);
    margin-top: 10px;
}

/* Settings groups */
.settings-group {
    margin-bottom: 24px;
}

.settings-group h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* Product grid */
.product-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.product-gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.product-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 { font-size: 16px; }

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-light);
}

.modal-body { padding: 20px; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Color picker */
input[type="color"] {
    width: 50px;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input { display: none; }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--primary);
}

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

/* Responsive */
@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }

    .admin-sidebar.mobile-open {
        transform: translateX(0);
    }

    .admin-main {
        margin-left: 0;
    }

    .mobile-toggle {
        display: block;
    }

    .sidebar-toggle {
        display: block;
    }

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

    .page-builder {
        grid-template-columns: 1fr;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .content-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .topbar-right {
        gap: 8px;
    }

    .user-name {
        display: none;
    }
}

/* Integrations */
.integration-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.integration-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: var(--primary-light);
    color: var(--primary);
}

.integration-info { flex: 1; }
.integration-info h4 { margin-bottom: 2px; }
.integration-info p { color: var(--text-light); font-size: 13px; }

/* Collapsible sidebar nav groups */
.nav-group {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.nav-section-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 12px 20px 8px;
    user-select: none;
    transition: background 0.15s;
}

.nav-section-toggle:hover {
    background: rgba(255,255,255,0.03);
}

.nav-section-toggle span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-section-toggle span i {
    width: 16px;
    font-size: 12px;
    text-align: center;
    color: var(--text-light);
}

.nav-arrow {
    font-size: 10px;
    transition: transform 0.25s ease;
    color: var(--text-light);
}

.nav-group.open .nav-arrow {
    transform: rotate(180deg);
}

.nav-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-group.open .nav-group-items {
    max-height: 600px;
}

/* Drag placeholder */
.sortable-ghost {
    opacity: 0.4;
    background: var(--primary-light);
}

.sortable-chosen {
    box-shadow: var(--shadow-lg);
}
