/* Mind Cloud Forms - Custom Styling */

/* ============ CSS Variables ============ */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-card-hover: #22222e;
    --bg-input: #0d0d12;

    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;

    --accent: #c8ff00;
    --accent-hover: #d4ff33;
    --accent-muted: rgba(200, 255, 0, 0.1);

    --border: #2a2a35;
    --border-focus: #3a3a45;

    --success: #00d26a;
    --error: #ff4757;
    --warning: #ffa502;

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

    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Playfair Display', Georgia, serif;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============ Typography ============ */
h1, h2, h3, h4 {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    line-height: 1.2;
}

h1 { font-size: 2.5rem; margin-bottom: 1rem; }
h2 { font-size: 2rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.5rem; margin-bottom: 0.5rem; }

p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

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

/* ============ Layout ============ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.container-narrow {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

/* ============ Header ============ */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.logo {
    font-family: var(--font-sans);
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.logo span { color: var(--accent); }

.header-nav {
    display: flex;
    gap: 1rem;
}

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    color: var(--bg-primary);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-focus);
}

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

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.btn-danger {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
}

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

.btn-sm { padding: 0.5rem 1rem; font-size: 0.85rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1rem; }

/* ============ Cards ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: all 0.2s;
}

.card:hover {
    border-color: var(--border-focus);
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.card-title {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1.25rem;
}

.card-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* ============ Forms ============ */
.form-group { margin-bottom: 1.5rem; }

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-label-optional {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    transition: all 0.2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

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

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

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23a0a0b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
}

.form-check input {
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.form-check input[type="radio"] { border-radius: 50%; }

.form-check input:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.form-check input:checked::after {
    content: '';
    display: block;
    width: 6px;
    height: 10px;
    border: solid var(--bg-primary);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(5px, -1px);
}

.form-check input[type="radio"]:checked::after {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: var(--bg-primary);
    transform: translate(5px, 5px);
}

.form-check-label {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ============ Form Builder ============ */
.builder-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    align-items: start;
}

.builder-preview {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    min-height: 400px;
}

.builder-sidebar {
    position: sticky;
    top: 2rem;
}

.field-types { display: grid; gap: 0.5rem; }

.field-type-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
}

.field-type-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

.field-type-icon {
    width: 20px;
    text-align: center;
    color: var(--accent);
}

/* Field Card (in builder) */
.field-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    cursor: grab;
    transition: all 0.2s;
}

.field-card:hover { border-color: var(--border-focus); }
.field-card.selected { border-color: var(--accent); }
.field-card.dragging { opacity: 0.5; cursor: grabbing; }

.field-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.field-card-type {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
}

.field-card-actions { display: flex; gap: 0.25rem; }

.field-card-btn {
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.field-card-btn:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.field-card-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.field-card-btn.delete:hover { color: var(--error); }

/* ============ Empty States ============ */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* ============ Grid ============ */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .builder-layout { grid-template-columns: 1fr; }
}

/* ============ Table ============ */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

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

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

.table th {
    background: var(--bg-secondary);
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-card); }

/* ============ Stats ============ */
.stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
}

.stat { text-align: center; }

.stat-value {
    font-size: 2.5rem;
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--accent);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============ Alerts ============ */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
}

.alert-success {
    background: rgba(0, 210, 106, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.alert-error {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

/* ============ Utilities ============ */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

/* ============ Success Page ============ */
.success-page {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2rem;
    color: var(--bg-primary);
}

/* ============ Hero Section ============ */
.form-hero {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, #1a1a2e 100%);
    padding: 3rem 2rem;
    text-align: center;
    margin-bottom: 2rem;
    border-radius: var(--radius-lg);
}

.form-hero h1 {
    font-size: 2.25rem;
    margin-bottom: 0.75rem;
}

.form-hero p {
    max-width: 600px;
    margin: 0 auto;
}

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

.animate-in { animation: fadeIn 0.3s ease-out; }

/* ============ Scrollbar ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-focus); }

/* ============ Builder Three-Column Layout ============ */
.builder-container {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    min-height: calc(100vh - 70px);
}

.forms-sidebar {
    position: sticky;
    top: 2rem;
    align-self: start;
    min-width: 0;
}

.forms-sidebar .card {
    width: 100%;
}

.forms-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 60vh;
    overflow-y: auto;
}

/* Form list items - moved to end of file */

.builder-main {
    min-width: 0;
}

@media (max-width: 900px) {
    .builder-container {
        grid-template-columns: 1fr;
    }
    .forms-sidebar {
        position: static;
    }
}

/* ============ Modal ============ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 1rem;
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ============ Header Nav Improvements ============ */
.nav-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 0.5rem;
}

.btn-danger-text {
    color: var(--error) !important;
}

.btn-danger-text:hover {
    background: rgba(255, 71, 87, 0.1) !important;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--accent);
    color: var(--bg-primary);
    border-radius: 9px;
    margin-left: 0.4rem;
}

/* ============ Form List Item with Delete ============ */
.form-list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    position: relative;
}

.form-list-item:hover {
    background: var(--bg-card-hover);
}

.form-list-item.active {
    background: var(--accent-muted);
    border-left: 2px solid var(--accent);
}

.form-list-link {
    flex: 1;
    padding: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    min-width: 0;
}

.form-list-item:hover .form-list-link,
.form-list-item.active .form-list-link {
    color: var(--text-primary);
}

.form-list-item.active .form-list-link {
    color: var(--accent);
}

.form-list-delete {
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-right: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.form-list-item:hover .form-list-delete {
    display: flex;
}

.form-list-delete:hover {
    background: rgba(255, 71, 87, 0.15);
    color: var(--error);
}

.form-list-title {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.form-list-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ============ Inline Field Editor ============ */
.field-editor-inline {
    margin-top: 1rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
}

.field-editor-inline .form-group {
    margin-bottom: 1rem;
}

.field-editor-inline .form-group:last-child {
    margin-bottom: 0;
}

.field-editor-inline h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--accent);
}
