/* ═══════════════════════════════════════════════════════════════════════════════
   SAMACV ADMIN DASHBOARD - PROFESSIONAL STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --primary-light: #8b9cf5;
    --secondary: #764ba2;
    --accent: #4299e1;
    --success: #48bb78;
    --warning: #ecc94b;
    --danger: #f56565;
    --dark: #1a202c;
    --gray-900: #1a202c;
    --gray-800: #2d3748;
    --gray-700: #4a5568;
    --gray-600: #718096;
    --gray-500: #a0aec0;
    --gray-400: #cbd5e0;
    --gray-300: #e2e8f0;
    --gray-200: #edf2f7;
    --gray-100: #f7fafc;
    --white: #ffffff;
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 65px;
    --border-radius: 8px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
}

.app {
    display: flex;
    min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════════ */

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--dark) 0%, var(--gray-800) 100%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .sidebar-header span,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-details {
    display: none;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
}

.logo i {
    font-size: 1.8rem;
    color: var(--primary);
}

.sidebar-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--white);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 20px;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-500);
    padding: 0 20px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--gray-400);
    text-decoration: none;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

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

.nav-item.active {
    background: rgba(102, 126, 234, 0.15);
    color: var(--white);
    border-left-color: var(--primary);
}

.nav-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

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

.avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════════════════════════ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: var(--transition);
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed);
}

.main-header {
    background: var(--white);
    padding: 0 30px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-left h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-700);
    cursor: pointer;
}

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

.search-box {
    display: flex;
    align-items: center;
    background: var(--gray-100);
    border-radius: var(--border-radius);
    padding: 8px 16px;
    gap: 8px;
}

.search-box i {
    color: var(--gray-500);
}

.search-box input {
    border: none;
    background: none;
    outline: none;
    width: 200px;
    font-size: 0.9rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--gray-200);
}

.icon-btn i {
    font-size: 1.2rem;
    color: var(--gray-700);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: var(--white);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 10px;
}

.content-area {
    padding: 30px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   PAGES
   ═══════════════════════════════════════════════════════════════════════════════ */

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
}

.page-header-content h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.page-header-content p {
    color: var(--gray-600);
}

.page-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   STATS CARDS
   ═══════════════════════════════════════════════════════════════════════════════ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

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

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon i {
    font-size: 1.75rem;
    color: var(--white);
}

.stat-icon.blue { background: linear-gradient(135deg, #667eea, #764ba2); }
.stat-icon.purple { background: linear-gradient(135deg, #9f7aea, #b794f4); }
.stat-icon.green { background: linear-gradient(135deg, #48bb78, #68d391); }
.stat-icon.orange { background: linear-gradient(135deg, #ed8936, #f6ad55); }

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-label {
    color: var(--gray-600);
    font-size: 0.9rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════════════════ */

.card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-900);
}

.card-body {
    padding: 24px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   QUICK ACTIONS
   ═══════════════════════════════════════════════════════════════════════════════ */

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 16px;
    background: var(--gray-50);
    border: 2px dashed var(--gray-300);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.quick-action-btn:hover {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.05);
}

.quick-action-btn i {
    font-size: 2rem;
    color: var(--primary);
}

.quick-action-btn span {
    font-weight: 500;
    color: var(--gray-700);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DOCUMENT TYPES GRID
   ═══════════════════════════════════════════════════════════════════════════════ */

.doc-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.doc-type-card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.doc-type-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.doc-type-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 24px;
    color: var(--white);
}

.doc-type-icon {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.doc-type-icon i {
    font-size: 1.5rem;
}

.doc-type-header h4 {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

.doc-type-header .slug {
    font-size: 0.85rem;
    opacity: 0.8;
}

.doc-type-body {
    padding: 20px 24px;
}

.doc-type-info {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.doc-type-info-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--gray-600);
}

.doc-type-info-item i {
    color: var(--primary);
}

.doc-type-actions {
    display: flex;
    gap: 8px;
}

.doc-type-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.doc-type-status.active {
    background: rgba(72, 187, 120, 0.1);
    color: var(--success);
}

.doc-type-status.inactive {
    background: rgba(245, 101, 101, 0.1);
    color: var(--danger);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TEMPLATES GRID
   ═══════════════════════════════════════════════════════════════════════════════ */

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.template-card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

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

.template-preview {
    height: 180px;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.template-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.template-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--gray-500);
}

.template-preview-placeholder i {
    font-size: 3rem;
}

.template-category-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.template-category-badge.modern { background: var(--primary); color: var(--white); }
.template-category-badge.traditional { background: var(--gray-700); color: var(--white); }
.template-category-badge.creative { background: #e74c3c; color: var(--white); }
.template-category-badge.executive { background: #1a1a2e; color: var(--white); }
.template-category-badge.minimal { background: var(--gray-400); color: var(--gray-900); }

.template-card-body {
    padding: 16px 20px;
}

.template-card-body h4 {
    font-size: 1rem;
    margin-bottom: 4px;
    color: var(--gray-900);
}

.template-card-body .doc-type {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.template-colors {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--white);
    box-shadow: var(--shadow-sm);
}

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

/* ═══════════════════════════════════════════════════════════════════════════════
   FIELDS PAGE
   ═══════════════════════════════════════════════════════════════════════════════ */

.fields-container {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    min-height: 400px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 16px;
}

.field-group-item {
    border-bottom: 1px solid var(--gray-200);
}

.field-group-item:last-child {
    border-bottom: none;
}

.field-group-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
}

.field-group-header:hover {
    background: var(--gray-50);
}

.field-group-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.field-group-info .drag-handle {
    color: var(--gray-400);
    cursor: grab;
}

.field-group-info h4 {
    font-size: 1rem;
    color: var(--gray-900);
}

.field-group-info .slug {
    font-size: 0.8rem;
    color: var(--gray-500);
}

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

.badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-primary { background: rgba(102, 126, 234, 0.1); color: var(--primary); }
.badge-success { background: rgba(72, 187, 120, 0.1); color: var(--success); }
.badge-warning { background: rgba(236, 201, 75, 0.2); color: #b7791f; }

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

.field-group-content {
    padding: 0 24px 20px;
    display: none;
}

.field-group-content.expanded {
    display: block;
}

.fields-list {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 16px;
}

.field-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border-radius: 6px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
}

.field-item:last-child {
    margin-bottom: 0;
}

.field-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.field-item-info .drag-handle {
    color: var(--gray-400);
    cursor: grab;
}

.field-item-info h5 {
    font-size: 0.9rem;
    color: var(--gray-800);
}

.field-item-info .type {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.add-field-btn {
    width: 100%;
    padding: 12px;
    border: 2px dashed var(--gray-300);
    background: none;
    border-radius: 6px;
    color: var(--gray-500);
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.add-field-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SIMULATOR
   ═══════════════════════════════════════════════════════════════════════════════ */

.simulator-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    height: calc(100vh - 200px);
}

.simulator-sidebar {
    overflow-y: auto;
}

.simulator-preview {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.preview-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.preview-actions {
    display: flex;
    gap: 8px;
}

.preview-content {
    flex: 1;
    padding: 20px;
    overflow: auto;
    background: var(--gray-200);
}

.preview-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--white);
    box-shadow: var(--shadow);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   BOT PREVIEW
   ═══════════════════════════════════════════════════════════════════════════════ */

.bot-preview-container {
    display: grid;
    grid-template-columns: 375px 1fr;
    gap: 30px;
    align-items: start;
}

.phone-mockup {
    background: var(--gray-900);
    border-radius: 40px;
    padding: 12px;
    box-shadow: var(--shadow-lg);
}

.phone-header {
    background: #075e54;
    border-radius: 28px 28px 0 0;
    overflow: hidden;
}

.phone-status-bar {
    display: flex;
    justify-content: space-between;
    padding: 8px 20px;
    font-size: 0.75rem;
    color: var(--white);
}

.phone-icons {
    display: flex;
    gap: 4px;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
}

.chat-info {
    display: flex;
    flex-direction: column;
    color: var(--white);
}

.chat-name {
    font-weight: 600;
}

.chat-status {
    font-size: 0.75rem;
    opacity: 0.8;
}

.phone-content {
    background: #e5ddd5;
    height: 500px;
    overflow-y: auto;
    padding: 16px;
}

.chat-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.chat-message.bot {
    background: var(--white);
    border-radius: 0 8px 8px 8px;
}

.chat-message.user {
    background: #dcf8c6;
    margin-left: auto;
    border-radius: 8px 0 8px 8px;
}

.phone-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: #f0f0f0;
    border-radius: 0 0 28px 28px;
}

.phone-input input {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
}

.phone-input button {
    width: 40px;
    height: 40px;
    background: #075e54;
    border: none;
    border-radius: 50%;
    color: var(--white);
    cursor: pointer;
}

.bot-config {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.code-block {
    background: var(--gray-900);
    color: #68d391;
    padding: 16px;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre-wrap;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SETTINGS PAGE
   ═══════════════════════════════════════════════════════════════════════════════ */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════════════════════ */

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-color {
    width: 60px;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    cursor: pointer;
}

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

.checkbox-label,
.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    margin-right: 16px;
}

.radio-group {
    display: flex;
    gap: 20px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #e53e3e;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 201;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal.modal-lg {
    max-width: 1200px;
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--gray-100);
}

.modal-close i {
    font-size: 1.25rem;
    color: var(--gray-500);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TEMPLATE EDITOR
   ═══════════════════════════════════════════════════════════════════════════════ */

.template-editor {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    height: 70vh;
}

.template-editor-sidebar {
    overflow-y: auto;
    padding-right: 10px;
}

.template-editor-main {
    display: flex;
    flex-direction: column;
    background: var(--gray-100);
    border-radius: 6px;
    overflow: hidden;
}

.editor-tabs {
    display: flex;
    background: var(--gray-200);
}

.editor-tab {
    padding: 12px 20px;
    border: none;
    background: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
}

.editor-tab.active {
    background: var(--white);
    color: var(--primary);
}

.editor-content {
    flex: 1;
    position: relative;
}

.editor-pane {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
}

.editor-pane.active {
    display: block;
}

.code-editor {
    width: 100%;
    height: 100%;
    padding: 16px;
    border: none;
    resize: none;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    background: var(--gray-900);
    color: #e2e8f0;
}

.preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--white);
}

.editor-toolbar {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    min-width: 300px;
}

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

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--primary); }

.toast i {
    font-size: 1.25rem;
}

.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
.toast.info i { color: var(--primary); }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.85rem;
    color: var(--gray-600);
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   IMAGE TO TEMPLATE CONVERTER
   ═══════════════════════════════════════════════════════════════════════════════ */

.image-converter-section {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    overflow: hidden;
}

.image-converter-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--white);
    cursor: pointer;
    font-weight: 500;
}

.image-converter-header i:first-child {
    font-size: 1.2rem;
}

.image-converter-header .btn {
    margin-left: auto;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
}

.image-converter-content {
    background: var(--white);
    padding: 16px;
    display: none;
}

.image-converter-content.expanded {
    display: block;
}

.image-upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--border-radius);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--gray-50);
    position: relative;
}

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

.image-upload-area.dragover {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.1);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--gray-500);
}

.upload-placeholder i {
    font-size: 2.5rem;
    color: var(--gray-400);
}

.upload-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--border-radius);
    object-fit: contain;
}

.conversion-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: var(--gray-100);
    border-radius: var(--border-radius);
    margin-top: 12px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-block {
    width: 100%;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════════════════ */

.text-muted {
    color: var(--gray-600);
}

.mb-3 {
    margin-bottom: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .mobile-menu-btn {
        display: block;
    }

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

    .simulator-container,
    .bot-preview-container {
        grid-template-columns: 1fr;
    }

    .template-editor {
        grid-template-columns: 1fr;
        height: auto;
    }

    .template-editor-sidebar {
        order: 2;
    }

    .template-editor-main {
        order: 1;
        height: 50vh;
    }
}

@media (max-width: 768px) {
    .content-area {
        padding: 20px;
    }

    .page-header {
        flex-direction: column;
        gap: 16px;
    }

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

    .doc-types-grid,
    .templates-grid {
        grid-template-columns: 1fr;
    }
}
