/* ==========================================================================
   SVG TEMPLATER DESIGN SYSTEM
   Premium minimalist dark theme - clean, structured, and focused.
   ========================================================================== */

:root {
    /* Modern Slate Palette */
    --bg-main: #0c0e15;
    --bg-card: #141724;
    --bg-input: #0a0b10;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(99, 102, 241, 0.4);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #4b5563;
    
    /* Vibrant Accent Colors */
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --pink: #ff79c6;
    
    /* Sizing & Transitions */
    --border-radius: 6px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Fonts */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* App Container Layout */
.app-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 100vh;
}

/* Header Navbar */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.logo-area h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

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

/* Inline Status Display */
.header-status {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-badge {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.pulse-dot.live {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.pulse-dot.demo {
    background-color: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.status-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-meta-item {
    border-left: 1px solid var(--border-color);
    padding-left: 12px;
}

.status-meta-item code, .status-meta-item span {
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* Workspace Layouts */
.workspace-area {
    flex-grow: 1;
}

.grid-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 24px;
    align-items: start;
}

.grid-layout-editor {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Cards System */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-header p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.card-body {
    padding: 20px;
    flex-grow: 1;
}

/* Drag-and-Drop Zone */
.drop-zone {
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 36px 16px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.01);
    position: relative;
    transition: var(--transition);
    overflow: hidden;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--border-hover);
    background: rgba(99, 102, 241, 0.02);
}

.file-input-hidden {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: none; /* Let clicks pass to the hidden absolute input */
}

.drop-icon {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.drop-zone:hover .drop-icon {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
    border-color: rgba(99, 102, 241, 0.25);
    transform: scale(1.05);
}

.drop-zone-content h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.drop-zone-content p {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* Beautiful virtual button inside drop zone */
.drop-zone-content p span {
    background: rgba(99, 102, 241, 0.08);
    color: var(--accent);
    border: 1px solid rgba(99, 102, 241, 0.15);
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    transition: var(--transition);
    margin-top: 4px;
}

.drop-zone:hover .drop-zone-content p span {
    background: var(--accent);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.file-limits {
    font-size: 10px;
    color: var(--text-muted);
}

/* Template Cards Grid */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.template-item {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    transition: var(--transition);
}

.template-item:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.02);
}

.template-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.template-icon-wrapper {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    border: 1px solid rgba(99, 102, 241, 0.1);
}

.template-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-id-sub {
    font-size: 11px;
    color: var(--text-secondary);
}

.template-id-sub code {
    font-family: var(--font-mono);
    color: var(--pink);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    padding: 1px 4px;
    border-radius: 2px;
}

.template-variable-count {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 50px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
}

.template-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

/* Universal Button Design */
.submit-btn, .template-btn-use, .back-btn, .preview-action-btn, .download-action-btn, .icon-btn-toggle, .template-btn-rename, .template-btn-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    padding: 8px 12px;
}

.submit-btn:hover, .template-btn-use:hover, .back-btn:hover, .preview-action-btn:hover, .icon-btn-toggle:hover, .template-btn-rename:hover, .template-btn-delete:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.07);
}

/* Specialized Buttons */
.submit-btn {
    width: 100%;
    background: var(--accent);
    color: #ffffff;
    border: none;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
}

.submit-btn:hover {
    background: var(--accent-hover);
}

.template-btn-use {
    flex-grow: 1;
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-primary);
    border-color: rgba(99, 102, 241, 0.2);
    gap: 6px;
}

.template-btn-use:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: transparent;
}

.template-btn-delete {
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
    border-color: rgba(239, 68, 68, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.template-btn-delete:hover {
    background: var(--danger);
    color: #ffffff;
    border-color: transparent;
}

.template-btn-rename {
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--pink);
    background: rgba(255, 121, 198, 0.05);
    border-color: rgba(255, 121, 198, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.template-btn-rename:hover {
    background: var(--pink);
    color: #ffffff;
    border-color: transparent;
}

.icon-btn-toggle {
    background: rgba(245, 158, 11, 0.05);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.15);
    padding: 6px 12px;
    gap: 6px;
}

.icon-btn-toggle.active {
    background: var(--warning);
    color: #000000;
    border-color: transparent;
}

.icon-btn-toggle.active:hover {
    background: #d97706;
}

/* Custom Input Field */
.custom-input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--border-radius);
    font-size: 13px;
    width: 100%;
    outline: none;
    transition: var(--transition);
}

.custom-input:focus {
    border-color: var(--accent);
}

.custom-input::placeholder {
    color: var(--text-muted);
}

/* Fonts Management */
.font-list-container {
    margin-top: 6px;
}

.font-list-container h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.font-list {
    list-style: none;
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: rgba(0, 0, 0, 0.1);
}

.font-item {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.font-item-icon {
    color: var(--warning);
    display: flex;
    align-items: center;
}

.font-list-empty {
    padding: 12px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
}

/* Editor Section */
.editor-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.active-template-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.active-template-title h2 {
    font-size: 15px;
    font-weight: 600;
}

.tag {
    background: rgba(168, 85, 247, 0.08);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.15);
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 50px;
}

.form-inputs-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.form-divider {
    height: 1px;
    background: var(--border-color);
    margin: 16px 0;
}

/* Output Options */
.rendering-settings {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.rendering-settings h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.setting-row label {
    font-size: 12px;
    color: var(--text-secondary);
}

.format-selector {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 2px;
    border-radius: var(--border-radius);
}

.format-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.format-btn:hover {
    color: var(--text-primary);
}

.format-btn.active {
    background: var(--accent);
    color: #ffffff;
}

.resolution-inputs {
    display: flex;
    gap: 8px;
    width: 160px;
}

.input-with-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
}

.input-with-label input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 11px;
    width: 100%;
    outline: none;
    text-align: center;
}

.input-with-label input:focus {
    border-color: var(--accent);
}

.input-with-label span {
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
}

/* Page Manager */
.pages-manager-card {
    margin-top: 0;
}

/* Live Viewport */
.preview-card {
    height: 100%;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.preview-action-btn {
    padding: 6px;
    width: 28px;
    height: 28px;
}

.zoom-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: var(--border-radius);
    height: 28px;
    display: inline-flex;
    align-items: center;
}

.download-action-btn {
    background: var(--accent);
    border: none;
    color: #ffffff;
    padding: 0 12px;
    height: 28px;
    font-size: 11px;
    font-weight: 600;
}

.download-action-btn:hover {
    background: var(--accent-hover);
}

.download-all-btn {
    background: var(--pink);
}

.download-all-btn:hover {
    background: #e062b0;
}

/* Preview Canvas Figma Grid Background */
.canvas-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #090a0f;
    padding: 0;
    min-height: 480px;
    max-height: 560px;
    position: relative;
    overflow: hidden;
}

.canvas-viewport {
    width: 100%;
    height: 100%;
    display: flex;
    overflow: auto;
    padding: 24px;
}

.canvas-container {
    position: relative;
    background-color: #0e111a;
    /* Soft premium low-contrast checkerboard */
    background-image: 
        linear-gradient(45deg, #141722 25%, transparent 25%), 
        linear-gradient(-45deg, #141722 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #141722 75%), 
        linear-gradient(-45deg, transparent 75%, #141722 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(100% * var(--zoom, 1));
    max-width: calc(760px * var(--zoom, 1));
    flex-shrink: 0;
    margin: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.canvas-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-secondary);
    text-align: center;
    padding: 48px;
}

.canvas-placeholder svg {
    color: var(--text-muted);
}

.canvas-placeholder p {
    font-size: 12px;
}

.pulse-opacity {
    animation: pulsing 2s infinite ease-in-out;
}

@keyframes pulsing {
    0% { opacity: 0.4; }
    50% { opacity: 0.8; }
    100% { opacity: 0.4; }
}

.canvas-container img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

.canvas-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(12, 14, 21, 0.8);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 100;
}

.canvas-loading p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Spinner */
.spinner {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-small {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-top: 2px solid var(--warning);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 8px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 0;
}

.loading-container p {
    font-size: 12px;
    color: var(--text-secondary);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    padding: 48px 16px;
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
}

.empty-state h3 {
    font-size: 13px;
    font-weight: 600;
}

.empty-state p {
    font-size: 11px;
    color: var(--text-secondary);
    max-width: 280px;
}

/* Fullscreen Mode Overlay */
.preview-card.fullscreen-active {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    border-radius: 0;
    border: none;
    background: var(--bg-main);
}

.preview-card.fullscreen-active .preview-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
}

.preview-card.fullscreen-active .canvas-body {
    height: calc(100vh - 53px);
    max-height: none;
    background: #08090d;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 500;
    min-width: 260px;
    max-width: 380px;
    animation: toastIn 0.2s ease-out;
    transition: var(--transition);
}

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

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

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

.toast-leave {
    opacity: 0 !important;
    transform: translateY(10px) scale(0.95) !important;
}

/* Footer Styling */
.app-footer {
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 11px;
}

/* View Toggling & Page Navigation */
.view-content {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.view-content.active {
    display: block;
    opacity: 1;
    animation: viewFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Utility Hidden */
.hidden {
    display: none !important;
}

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

@media (max-width: 640px) {
    .app-container {
        padding: 16px 12px;
        gap: 16px;
    }
    
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .header-status {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .status-meta {
        padding-left: 0;
        width: 100%;
        justify-content: space-between;
    }
    
    .status-meta-item:first-child {
        border-left: none;
        padding-left: 0;
    }
}
