/* ============================================
   AppsMaker AI - Main Stylesheet
   Flat, solid, squared design. No shadows/gradients/radius.
   ============================================ */

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

:root {
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --primary-light: #EFF6FF;
    --dark: #0f172a;
    --dark-2: #1e293b;
    --dark-3: #334155;
    --text: #334155;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --bg: #f8fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    --border-dark: #cbd5e1;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --info: #0891b2;
    --info-bg: #ecfeff;
    --sidebar-width: 260px;
    --topbar-height: 56px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;
}

html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    height: auto;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--dark);
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 2.4rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.15rem; }

p { margin-bottom: 1rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    border: 2px solid transparent;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

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

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

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

.btn-dark:hover {
    background: var(--dark-2);
    border-color: var(--dark-2);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    color: var(--dark);
    border-color: var(--border-dark);
}

.btn-outline:hover {
    background: var(--dark);
    color: var(--white);
    border-color: var(--dark);
}

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

.btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: var(--white);
}

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

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

.btn-ghost:hover {
    background: var(--border);
}

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

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.btn:disabled, .btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--font);
    color: var(--text);
    background: var(--white);
    border: 2px solid var(--border);
    transition: border-color 0.15s;
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
}

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

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

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Cards */
.card {
    background: var(--white);
    border: 2px solid var(--border);
    padding: 24px;
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
}

/* Alerts */
.alert {
    padding: 14px 18px;
    margin-bottom: 20px;
    border: 2px solid;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success);
    color: #166534;
}

.alert-error {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: #991b1b;
}

.alert-warning {
    background: var(--warning-bg);
    border-color: var(--warning);
    color: #92400e;
}

.alert-info {
    background: var(--info-bg);
    border-color: var(--info);
    color: #155e75;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    font-size: 14px;
}

th {
    font-weight: 600;
    color: var(--dark);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    background: var(--bg);
}

tr:hover td {
    background: var(--primary-light);
}

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

.badge-primary { background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.badge-dark { background: var(--dark); color: var(--white); }

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

.stat-card {
    background: var(--white);
    border: 2px solid var(--border);
    padding: 20px;
}

.stat-card .stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
}

.stat-card .stat-change {
    font-size: 12px;
    margin-top: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--dark);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

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

.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;
    font-family: var(--font);
}

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

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

/* Pagination */
.pagination {
    display: flex;
    gap: 4px;
    margin-top: 24px;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    font-size: 13px;
    border: 2px solid var(--border);
    color: var(--text);
    background: var(--white);
}

.pagination a:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.modal {
    background: var(--white);
    border: 2px solid var(--border);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

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

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

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

.modal-body {
    padding: 24px;
}

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

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border: 2px solid var(--border);
    min-width: 180px;
    z-index: 100;
    display: none;
}

.dropdown.active .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.dropdown-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

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

/* ============================================
   LANDING PAGE
   ============================================ */

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    height: 64px;
    background: var(--white);
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-logo img {
    height: 32px;
}

.navbar-links {
    display: flex;
    gap: 32px;
    list-style: none;
}

.navbar-links a {
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

.navbar-links a:hover {
    color: var(--primary);
}

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

.navbar-toggle {
    display: none;
    background: none;
    border: 2px solid var(--border);
    padding: 8px;
    cursor: pointer;
    font-size: 18px;
}

/* Hero */
.hero {
    padding: 100px 40px 80px;
    text-align: center;
    background: var(--white);
    border-bottom: 2px solid var(--border);
}

.hero h1 {
    font-size: 3.2rem;
    font-weight: 800;
    margin-bottom: 20px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.1;
}

.hero h1 span {
    color: var(--primary);
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-light);
    max-width: 600px;
    margin: 0 auto 36px;
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
    margin-top: 60px;
    padding-top: 40px;
    border-top: 2px solid var(--border);
}

.hero-stat {
    text-align: center;
}

.hero-stat .num {
    font-size: 2rem;
    font-weight: 800;
    color: var(--dark);
}

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

/* Sections */
.section {
    padding: 80px 40px;
}

.section-alt {
    background: var(--white);
    border-top: 2px solid var(--border);
    border-bottom: 2px solid var(--border);
}

.section-header {
    text-align: center;
    margin-bottom: 60px;
}

.section-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.section-header p {
    color: var(--text-light);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.feature-card {
    background: var(--white);
    border: 2px solid var(--border);
    padding: 32px;
    transition: border-color 0.15s;
}

.section-alt .feature-card {
    background: var(--bg);
}

.feature-card:hover {
    border-color: var(--primary);
}

.feature-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 20px;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.feature-card h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.feature-card p {
    color: var(--text-light);
    font-size: 14px;
    margin: 0;
    line-height: 1.6;
}

/* How It Works */
.steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    counter-reset: step;
}

.step {
    text-align: center;
    counter-increment: step;
}

.step-num {
    width: 56px;
    height: 56px;
    background: var(--dark);
    color: var(--white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
}

.step h3 {
    margin-bottom: 8px;
}

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

/* Pricing */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.pricing-card {
    background: var(--white);
    border: 2px solid var(--border);
    padding: 32px;
    display: flex;
    flex-direction: column;
}

.pricing-card.featured {
    border-color: var(--primary);
    position: relative;
}

.pricing-card.featured::before {
    content: 'MOST POPULAR';
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: var(--white);
    padding: 4px 16px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
}

.pricing-card .plan-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.pricing-card .plan-price {
    font-size: 36px;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 4px;
}

.pricing-card .plan-price span {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-muted);
}

.pricing-card .plan-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--border);
}

.pricing-card ul {
    list-style: none;
    margin-bottom: 24px;
    flex: 1;
}

.pricing-card li {
    padding: 6px 0;
    font-size: 14px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.pricing-card li::before {
    content: '✓';
    color: var(--success);
    font-weight: 700;
}

.pricing-card li.disabled {
    color: var(--text-muted);
    text-decoration: line-through;
}

.pricing-card li.disabled::before {
    content: '✗';
    color: var(--text-muted);
}

/* CTA */
.cta {
    background: var(--dark);
    color: var(--white);
    padding: 80px 40px;
    text-align: center;
    border-top: 2px solid var(--dark);
}

.cta h2 {
    color: var(--white);
    font-size: 2.2rem;
    margin-bottom: 16px;
}

.cta p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 32px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* Footer */
.footer {
    padding: 40px;
    border-top: 2px solid var(--border);
    background: var(--white);
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    font-size: 13px;
    color: var(--text-muted);
}

.footer-links a:hover {
    color: var(--primary);
}

/* ============================================
   AUTH PAGES
   ============================================ */

.auth-page {
    min-height: calc(100vh - 64px - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border: 2px solid var(--border);
    padding: 40px;
}

.auth-card h2 {
    font-size: 1.6rem;
    margin-bottom: 8px;
}

.auth-card .auth-subtitle {
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 14px;
}

.auth-card .auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-light);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 2px;
    background: var(--border);
}

/* ============================================
   DASHBOARD
   ============================================ */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 1.6rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0;
}

/* Project Cards */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.project-card {
    background: var(--white);
    border: 2px solid var(--border);
    padding: 24px;
    transition: border-color 0.15s;
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    border-color: var(--primary);
}

.project-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.project-card h3 {
    font-size: 16px;
    margin-bottom: 0;
}

.project-card h3 a {
    color: var(--dark);
}

.project-card h3 a:hover {
    color: var(--primary);
}

.project-card .project-desc {
    color: var(--text-light);
    font-size: 13px;
    margin-bottom: 16px;
    flex: 1;
}

.project-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

/* Presets Grid */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.preset-card {
    background: var(--white);
    border: 2px solid var(--border);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s;
}

.preset-card:hover,
.preset-card.selected {
    border-color: var(--primary);
}

.preset-card.selected {
    background: var(--primary-light);
}

.preset-card .preset-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.preset-card .preset-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
}

.preset-card .preset-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================
   EDITOR (Project Builder)
   ============================================ */

.editor-layout {
    display: grid;
    grid-template-columns: 280px 1fr 380px;
    height: calc(100vh - var(--topbar-height));
    overflow: hidden;
}

body.chat-collapsed .editor-layout {
    grid-template-columns: 280px 1fr 0;
}

body.preview-mode .editor-layout {
    grid-template-columns: 0 1fr 0;
}

.editor-sidebar {
    background: var(--white);
    border-right: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-sidebar-header {
    padding: 16px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.editor-sidebar-header h3 {
    font-size: 14px;
}

.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    border-left: 3px solid transparent;
}

.file-item:hover {
    background: var(--primary-light);
}

.file-item.active {
    background: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
}

.file-item .file-icon {
    font-size: 14px;
    opacity: 0.5;
}

.file-status {
    color: #64748b;
}

.file-item.new-file {
    animation: fileSlideIn 0.3s ease forwards;
}

@keyframes fileSlideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

.file-status.done {
    color: #22c55e;
}

.file-status.generating {
    color: #3B82F6;
    animation: pulse 1.5s ease-in-out infinite;
}

.file-status.pending {
    color: #94a3b8;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.file-status.done {
    color: #16a34a;
}

.file-status.generating {
    color: #f59e0b;
    position: relative;
    overflow: hidden;
}

.file-status.generating::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -6px;
    width: 6px;
    height: calc(100% + 4px);
    background: rgba(255, 255, 255, 0.5);
    filter: blur(2px);
    animation: fileShimmer 1.1s linear infinite;
}

@keyframes fileShimmer {
    0% { transform: translateX(-8px); opacity: 0; }
    50% { opacity: 0.9; }
    100% { transform: translateX(120%); opacity: 0; }
}

.editor-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--white);
}

.editor-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    background: var(--bg);
    overflow-x: hidden;
    flex-shrink: 0;
    scrollbar-width: none;
}

.editor-tabs::-webkit-scrollbar {
    display: none;
}

.editor-tab {
    padding: 10px 20px;
    font-size: 13px;
    color: var(--text-light);
    cursor: pointer;
    border-right: 1px solid var(--border);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    font-family: var(--font);
}

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

.editor-tab .close-tab {
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.1s;
}

.editor-tab:hover .close-tab {
    opacity: 0.5;
}

.code-area {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.code-area > .empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.code-area pre {
    margin: 0;
    padding: 16px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    tab-size: 4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.code-area textarea {
    width: 100%;
    flex: 1;
    border: none;
    padding: 16px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    outline: none;
    tab-size: 4;
    background: var(--white);
    color: var(--text);
    overflow: auto;
}

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

 .preview-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 2px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.preview-btn {
    background: var(--white);
    border: 2px solid var(--border);
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text);
}

.preview-btn.active {
    border-color: var(--primary);
    color: var(--primary);
}

.preview-stage {
    flex: 1;
    overflow: auto;
    background: #0f172a;
    padding: 24px;
    display: none;
    justify-content: center;
    align-items: flex-start;
}

.preview-stage iframe {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    min-height: 600px;
}

/* Preview mode: focus on the preview only */
body.preview-mode .editor-sidebar,
body.preview-mode .editor-chat {
    display: none !important;
}

body.preview-mode .editor-main {
    flex: 1 1 auto;
}

body.preview-mode #code-area {
    display: none !important;
}

body.preview-mode .preview-toolbar {
    display: flex !important;
}

body.preview-mode .preview-stage {
    display: flex !important;
}

.editor-chat {
    background: var(--bg);
    border-left: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 360px;
    transition: width 0.2s ease, transform 0.2s ease;
}

.editor-chat.collapsed {
    width: 0;
    border-left: none;
    transform: translateX(100%);
}

.chat-header {
    padding: 16px;
    border-bottom: 2px solid var(--border);
    background: var(--white);
    flex-shrink: 0;
}

.chat-header h3 {
    font-size: 14px;
    margin-bottom: 2px;
}

.chat-header p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-msg {
    max-width: 90%;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
}

.chat-msg.user {
    background: var(--primary);
    color: var(--white);
    align-self: flex-end;
}

.chat-msg.ai {
    background: var(--white);
    border: 2px solid var(--border);
    align-self: flex-start;
}

.chat-msg.ai pre {
    background: var(--bg);
    padding: 8px;
    margin: 8px 0;
    font-family: var(--mono);
    font-size: 12px;
    overflow-x: auto;
    border: 1px solid var(--border);
}

.chat-msg.system {
    background: var(--info-bg);
    border: 1px solid var(--info);
    color: var(--dark);
    align-self: center;
    text-align: center;
    font-size: 13px;
    width: 100%;
}

.chat-input-area {
    padding: 16px;
    border-top: 2px solid var(--border);
    background: var(--white);
    flex-shrink: 0;
}

.chat-input-wrap {
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    resize: none;
    min-height: 42px;
    max-height: 120px;
}

.chat-input:focus {
    border-color: var(--primary);
}

.chat-send {
    background: var(--primary);
    color: var(--white);
    border: 2px solid var(--primary);
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    white-space: nowrap;
}

.chat-send:hover {
    background: var(--primary-hover);
}

.chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   BILLING / PLANS
   ============================================ */

.plan-current {
    border: 2px solid var(--success);
    position: relative;
}

.plan-current::after {
    content: 'CURRENT PLAN';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: var(--white);
    padding: 2px 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
}

/* ============================================
   SEO EDITOR
   ============================================ */

.seo-preview {
    background: var(--bg);
    border: 2px solid var(--border);
    padding: 20px;
    margin-bottom: 24px;
}

.seo-preview .seo-title {
    font-size: 18px;
    color: #1a0dab;
    margin-bottom: 4px;
    font-weight: 400;
}

.seo-preview .seo-url {
    font-size: 13px;
    color: #006621;
    margin-bottom: 4px;
}

.seo-preview .seo-desc {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.5;
}

/* ============================================
   DATABASE MANAGEMENT
   ============================================ */

.db-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.db-status .dot {
    width: 10px;
    height: 10px;
    display: inline-block;
}

.db-status .dot.connected { background: var(--success); }
.db-status .dot.disconnected { background: var(--danger); }

.db-providers {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.db-provider {
    border: 2px solid var(--border);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s;
    background: var(--white);
}

.db-provider:hover,
.db-provider.selected {
    border-color: var(--primary);
}

.db-provider h4 {
    font-size: 14px;
    margin-bottom: 4px;
}

.db-provider p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

/* ============================================
   LOADING
   ============================================ */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(248, 250, 252, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    flex-direction: column;
    gap: 16px;
}

.loading-overlay .spinner {
    width: 32px;
    height: 32px;
}

.loading-overlay p {
    color: var(--text-muted);
    font-size: 14px;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.p-0 { padding: 0; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

.d-flex { display: flex; }
.d-grid { display: grid; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.flex-1 { flex: 1; }

.w-full { width: 100%; }
.hidden { display: none !important; }
.visible { display: block !important; }

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }

    .editor-sidebar {
        display: none;
    }

    .editor-sidebar.mobile-open {
        display: flex;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 200;
    }

    .editor-chat {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 380px;
        z-index: 200;
        display: flex;
    }

    .editor-chat.collapsed {
        display: none;
    }

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

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

    .steps {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

@media (max-width: 768px) {
    html { font-size: 14px; }

    .hero {
        padding: 60px 20px 50px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero-stats {
        gap: 24px;
        flex-wrap: wrap;
    }

    .section {
        padding: 50px 20px;
    }

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

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

    .navbar {
        padding: 0 20px;
    }

    .navbar-links {
        display: none;
    }

    .navbar-links.mobile-open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--white);
        border-bottom: 2px solid var(--border);
        padding: 16px 20px;
        gap: 12px;
        z-index: 99;
    }

    .navbar-toggle {
        display: block;
    }

    .navbar-actions .btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .hero-actions {
        flex-direction: column;
        align-items: center;
    }

    .footer-inner {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 24px;
    }

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

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .editor-chat {
        width: 100%;
    }

    .editor-sidebar.mobile-open {
        width: 100%;
    }

    .cta {
        padding: 50px 20px;
    }

    .cta h2 {
        font-size: 1.6rem;
    }

    .modal {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.6rem;
    }

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

/* Print */
@media print {
    .navbar, .footer, .sidebar, .editor-chat, .chat-input-area {
        display: none !important;
    }
}

/* ============================================
   ROUNDED CORNERS
   ============================================ */

.btn,
.form-input,
.form-select,
.form-textarea,
.card,
.stat-card,
.project-card,
.preset-card,
.badge,
.alert,
.modal,
.dropdown-menu,
.feature-card,
.pricing-card,
.auth-card,
.seo-preview,
.db-provider,
.chat-msg,
.file-item,
.pagination a,
.pagination span,
.chat-input,
.chat-send {
    border-radius: 5px;
}

.spinner {
    border-radius: 50%;
}

/* ============================================
   DARK PURPLE THEME (Dashboard)
   ============================================ */

body.dark-theme {
    --primary: #94a3b8;
    --primary-hover: #cbd5e1;
    --primary-light: rgba(255, 255, 255, 0.06);
    --dark: #f1f5f9;
    --dark-2: #e2e8f0;
    --dark-3: #cbd5e1;
    --text: #cbd5e1;
    --text-light: #94a3b8;
    --text-muted: #64748b;
    --bg: #191919;
    --white: #242424;
    --border: #2e2e2e;
    --border-dark: #3d3d3d;
    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.1);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.1);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.1);
    --info: #38bdf8;
    --info-bg: rgba(56, 189, 248, 0.1);
}

/* Keep white text on colored buttons/elements */
body.dark-theme .btn-primary,
body.dark-theme .btn-primary:hover,
body.dark-theme .btn-dark,
body.dark-theme .btn-dark:hover,
body.dark-theme .btn-danger,
body.dark-theme .btn-danger:hover,
body.dark-theme .btn-success,
body.dark-theme .chat-send,
body.dark-theme .chat-send:hover,
body.dark-theme .pagination .active,
body.dark-theme .step-num {
    color: #ffffff;
}

/* Purple ONLY for primary action buttons */
body.dark-theme .btn-primary {
    background: #8b5cf6;
    border-color: #8b5cf6;
}

body.dark-theme .btn-primary:hover {
    background: #7c3aed;
    border-color: #7c3aed;
}

body.dark-theme .chat-send {
    background: #8b5cf6;
    border-color: #8b5cf6;
}

body.dark-theme .pagination .active {
    background: #8b5cf6;
    border-color: #8b5cf6;
}

body.dark-theme .btn-outline {
    color: #e2e8f0;
    border-color: #3a3a3a;
}

body.dark-theme .btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #94a3b8;
    color: #ffffff;
}

body.dark-theme .btn-ghost {
    color: #cbd5e1;
}

body.dark-theme .btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-theme .badge-primary {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border-color: rgba(139, 92, 246, 0.4);
}

body.dark-theme .badge-dark {
    background: #3a3a3a;
    color: #e2e8f0;
}

body.dark-theme a {
    color: #cbd5e1;
}

body.dark-theme a:hover {
    color: #f1f5f9;
}

body.dark-theme .project-card h3 a {
    color: #f1f5f9;
}

body.dark-theme .project-card h3 a:hover {
    color: #ffffff;
}

body.dark-theme .spinner {
    border-color: #2e2e2e;
    border-top-color: #94a3b8;
}

body.dark-theme .loading-overlay {
    background: rgba(25, 25, 25, 0.9);
}

body.dark-theme .chat-msg.ai pre {
    background: #1e1e1e;
    border-color: #2a2a2a;
}

body.dark-theme .code-area textarea {
    background: #1e1e1e;
    color: #e2e8f0;
}

/* Dark scrollbars for dashboard */
body.dark-theme ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

body.dark-theme ::-webkit-scrollbar-track {
    background: #1a1a1a;
}

body.dark-theme ::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 4px;
}

body.dark-theme ::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

body.dark-theme ::-webkit-scrollbar-corner {
    background: #1a1a1a;
}

body.dark-theme .editor-tabs {
    background: #1e1e1e;
}

body.dark-theme .editor-tab {
    color: #94a3b8;
    border-right-color: #2a2a2a;
}

body.dark-theme .editor-tab.active {
    background: #242424;
    color: #f1f5f9;
    border-bottom-color: #8b5cf6;  /* purple accent line */
}

body.dark-theme .chat-msg.system {
    background: rgba(255, 255, 255, 0.03);
    border-color: #2e2e2e;
    color: #cbd5e1;
}

body.dark-theme th {
    background: #1e1e1e;
}

body.dark-theme tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

body.dark-theme .form-label {
    color: #e2e8f0;
}

body.dark-theme ::placeholder {
    color: #64748b;
}

body.dark-theme .preset-card.selected {
    background: #2a2a2a;
}

body.dark-theme .empty-state h3 {
    color: #f1f5f9;
}

body.dark-theme .editor-sidebar-header {
    background: #242424;
    border-bottom-color: #2e2e2e;
}

body.dark-theme .editor-sidebar-header h3 {
    color: #f1f5f9;
}

body.dark-theme .chat-header {
    background: #242424;
    border-bottom-color: #2e2e2e;
}

body.dark-theme .chat-header h3 {
    color: #f1f5f9;
}

body.dark-theme .chat-input-area {
    background: #242424;
    border-top-color: #2e2e2e;
}

body.dark-theme .file-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-theme .file-item.active {
    background: #2a2a2a;
    color: #f1f5f9;
    border-left-color: #8b5cf6;  /* purple accent line */
}

body.dark-theme .editor-topbar {
    background: #242424;
    border-bottom-color: #2e2e2e;
}

body.dark-theme .editor-topbar__name {
    color: #f1f5f9;
}

body.dark-theme .mobile-editor-toggle {
    border-color: #3a3a3a;
    color: #cbd5e1;
}

body.dark-theme .mobile-editor-toggle:hover {
    border-color: #94a3b8;
    color: #f1f5f9;
}
