/* ===== CSS Variables ===== */
:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --accent-primary: #3b82f6;
    --accent-secondary: #60a5fa;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;

    --border-color: #e2e8f0;
    --border-focus: var(--accent-primary);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --sidebar-width: 280px;
    --toolbar-height: 56px;
    --panel-width: 300px;

    --transition: 0.2s ease;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
}

/* ===== App Layout ===== */
.app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-section {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.section-title .icon {
    font-size: 0.875rem;
}

/* ===== Components List ===== */
.components-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.component-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: grab;
    transition: all var(--transition);
}

.component-item:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.component-item:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.component-icon {
    font-size: 1.125rem;
}

.component-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ===== Templates Grid ===== */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.template-card {
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.template-card:hover {
    border-color: var(--accent-secondary);
}

.template-card.active {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.template-preview {
    height: 60px;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.minimal-preview {
    background: linear-gradient(to bottom, #f8fafc 50%, #e2e8f0 50%);
}

.modern-preview {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
}

.creative-preview {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.pro-preview {
    background: linear-gradient(135deg, #0f172a, #334155);
}

.template-card span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ===== Settings ===== */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.setting-item label:first-child {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.color-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-picker input[type="color"] {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
}

.color-value {
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--text-muted);
}

select {
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
}

/* Switch Toggle */
.switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    background: var(--bg-tertiary);
    border-radius: 24px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition);
}

.slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.switch input:checked+.slider {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.switch input:checked+.slider::before {
    transform: translateX(20px);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== Toolbar ===== */
.toolbar {
    height: var(--toolbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar-center {
    font-weight: 600;
    color: var(--text-primary);
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.toolbar-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.toolbar-btn.primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.toolbar-btn.primary:hover {
    background: var(--accent-secondary);
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 0.5rem;
}

/* ===== Canvas Area ===== */
.canvas-wrapper {
    flex: 1;
    padding: 2rem;
    overflow: auto;
    background: var(--bg-primary);
    background-image:
        radial-gradient(circle, var(--border-color) 1px, transparent 1px);
    background-size: 20px 20px;
}

.canvas {
    max-width: 900px;
    margin: 0 auto;
    min-height: 100%;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.drop-zone {
    min-height: 600px;
    padding: 1rem;
}

.drop-placeholder {
    height: 100%;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--text-muted);
    transition: all var(--transition);
}

.drop-zone.drag-over .drop-placeholder {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.05);
}

.drop-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.drop-placeholder p {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.drop-hint {
    font-size: 0.875rem;
}

/* ===== Canvas Components ===== */
.canvas-component {
    position: relative;
    padding: 1.5rem;
    margin: 0.5rem;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    transition: all var(--transition);
    cursor: pointer;
}

.canvas-component:hover {
    border-color: var(--accent-primary);
}

.canvas-component.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.component-actions {
    position: absolute;
    top: -12px;
    right: 8px;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity var(--transition);
}

.canvas-component:hover .component-actions,
.canvas-component.selected .component-actions {
    opacity: 1;
}

.action-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition);
}

.action-btn:hover {
    background: var(--accent-primary);
    color: white;
}

.action-btn.delete:hover {
    background: var(--accent-danger);
}

/* Component Styles */
.comp-header {
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    padding: 2rem;
    color: white;
    text-align: center;
}

.comp-hero {
    padding: 4rem 2rem;
    text-align: center;
    background: linear-gradient(135deg, #f8fafc, #e0e7ff);
}

.comp-hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.comp-hero p {
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto;
}

.comp-about {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem;
    align-items: center;
}

.about-image {
    width: 150px;
    height: 150px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    margin: 0 auto;
}

.comp-skills {
    padding: 2rem;
}

.skills-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.skill-tag {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 50px;
    font-size: 0.875rem;
}

.comp-projects {
    padding: 2rem;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.project-card {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.project-thumb {
    height: 100px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}

.comp-contact {
    padding: 2rem;
    text-align: center;
    background: var(--bg-tertiary);
}

.contact-form {
    max-width: 400px;
    margin: 1rem auto 0;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.form-btn {
    width: 100%;
    padding: 0.875rem;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 600;
    cursor: pointer;
}

.comp-footer {
    padding: 1.5rem;
    text-align: center;
    background: #0f172a;
    color: white;
}

/* ===== Properties Panel ===== */
.properties-panel {
    width: var(--panel-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: none;
    flex-direction: column;
}

.properties-panel.active {
    display: flex;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.close-panel {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
}

.close-panel:hover {
    color: var(--text-primary);
}

.panel-content {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
}

.no-selection {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 2rem;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 450px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.125rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 1.5rem;
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}

.export-option:hover {
    border-color: var(--accent-secondary);
}

.export-option.selected {
    border-color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.1);
}

.option-icon {
    font-size: 2rem;
}

.option-info h4 {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.option-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.export-confirm {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.export-confirm:hover {
    background: var(--accent-secondary);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-success);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1001;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-icon {
    color: var(--accent-success);
    font-weight: bold;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }

    .properties-panel {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .toolbar-center {
        display: none;
    }
}