/* Chipgrid - Claymorphism & Liquid Glass Design */

:root {
    /* Light Mode Colors */
    --bg-primary: #f0f4f8;
    --bg-secondary: rgba(255, 255, 255, 0.7);
    --bg-tertiary: rgba(255, 255, 255, 0.5);
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --accent: #667eea;
    --accent-bright: #764ba2;
    --grid-color: rgba(0, 0, 0, 0.05);
    --error: #f56565;
    --success: #48bb78;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
    --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

body.light-mode {
    --bg-primary: #f0f4f8;
    --bg-secondary: rgba(255, 255, 255, 0.7);
    --bg-tertiary: rgba(255, 255, 255, 0.5);
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --accent: #667eea;
    --accent-bright: #764ba2;
    --grid-color: rgba(0, 0, 0, 0.05);
    --error: #f56565;
    --success: #48bb78;
}

body:not(.light-mode) {
    --bg-primary: #0f1419;
    --bg-secondary: rgba(26, 32, 44, 0.7);
    --bg-tertiary: rgba(45, 55, 72, 0.5);
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --accent: #667eea;
    --accent-bright: #764ba2;
    --grid-color: rgba(255, 255, 255, 0.05);
    --error: #fc8181;
    --success: #68d391;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Claymorphism Button Style */
.clay-button {
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm), var(--shadow-inner);
    position: relative;
    overflow: hidden;
}

.clay-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.clay-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), var(--shadow-inner);
}

.clay-button:hover::before {
    opacity: 1;
}

.clay-button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm), var(--shadow-inner);
}

/* Liquid Glass Panel Style */
.glass-panel {
    background: var(--bg-secondary);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.glass-panel::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05));
    border-radius: 24px;
    z-index: -1;
    opacity: 0.5;
}

/* App Container */
#app {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Toolbar */
.toolbar {
    background: var(--bg-secondary);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 1000;
}

.toolbar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 100%);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    user-select: none;
}

.logo-img {
    height: 48px;
    scale: 150%;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.toolbar-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    background: var(--bg-tertiary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    padding: 8px 16px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    background: var(--bg-secondary);
}

.btn:hover::before {
    opacity: 1;
}

.btn:active {
    transform: translateY(0);
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* Theme Toggle */
.theme-toggle {
    background: var(--bg-tertiary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.theme-toggle:active {
    transform: scale(0.95);
}

#themeIcon {
    font-size: 20px;
}

/* Main Container */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Component Panel */
.component-panel {
    width: 280px;
    background: var(--bg-secondary);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
    padding: 20px 16px;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 100;
}

.component-panel::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg,
    transparent 0%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 100%);
}

.component-panel::-webkit-scrollbar {
    width: 8px;
}

.component-panel::-webkit-scrollbar-track {
    background: transparent;
}

.component-panel::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
    backdrop-filter: blur(10px);
}

.component-panel::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.component-section {
    margin-bottom: 24px;
}

.component-section h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.component-item {
    background: var(--bg-tertiary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.component-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.component-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    background: var(--bg-secondary);
}

.component-item:hover::before {
    opacity: 1;
}

.component-item:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.component-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    box-shadow: var(--shadow-inner);
    flex-shrink: 0;
}

.component-item span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#canvas {
    width: 100%;
    height: 100%;
    cursor: default;
    image-rendering: pixelated;
}

#canvas.grabbing {
    cursor: grabbing;
}

#canvas.connecting {
    cursor: crosshair;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    bottom: 80px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.zoom-btn {
    width: 44px;
    height: 44px;
    background: var(--bg-secondary);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    transform: scale(1.1);
    background: var(--accent);
    color: white;
    box-shadow: var(--shadow-lg);
}

.zoom-btn:active {
    transform: scale(0.95);
}

/* Status Bar */
.status-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 24px;
    display: flex;
    gap: 32px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

.status-item {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.status-value {
    color: var(--accent);
    font-weight: 700;
    margin-left: 8px;
}

/* Properties Panel */
.properties-panel {
    position: fixed;
    top: 80px;
    right: 24px;
    width: 320px;
    max-height: calc(100vh - 160px);
    background: var(--bg-secondary);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 500;
    overflow: hidden;
}

.properties-panel.active {
    opacity: 1;
    transform: translateX(0);
}

.properties-header {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-bright) 100%);
    padding: 16px 20px;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
}

.properties-title {
    font-size: 16px;
    font-weight: 700;
    color: white;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    width: 28px;
    height: 28px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.properties-content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 240px);
}

.properties-content::-webkit-scrollbar {
    width: 6px;
}

.properties-content::-webkit-scrollbar-track {
    background: transparent;
}

.properties-content::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.property-row {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.property-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.property-input {
    background: var(--bg-tertiary);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-inner);
}

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

.property-description {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border-left: 4px solid var(--accent);
}

.property-description h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.property-description p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--bg-secondary);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 24px;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.9) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.modal-header {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-bright) 100%);
    padding: 20px 24px;
    font-size: 18px;
    font-weight: 700;
    color: white;
    border-radius: 24px 24px 0 0;
    position: relative;
}

.modal-body {
    padding: 24px;
}

.example-item {
    padding: 16px;
    background: var(--bg-tertiary);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 12px;
}

.example-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: var(--bg-secondary);
}

/* Notification */
.notification {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    padding: 16px 24px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 500px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.notification.success {
    border-left: 4px solid var(--success);
}

.notification.error {
    border-left: 4px solid var(--error);
}

.notification.info {
    border-left: 4px solid var(--accent);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .component-panel {
        width: 240px;
    }

    .properties-panel {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .toolbar {
        padding: 8px 12px;
    }

    .toolbar-group {
        gap: 4px;
    }

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

    .component-panel {
        width: 200px;
        padding: 12px 8px;
    }

    .properties-panel {
        width: 100%;
        max-width: 320px;
        right: 12px;
        left: 12px;
        margin: 0 auto;
    }
}

/* Utility Classes */
.text-gradient {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-bright) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass-effect {
    background: var(--bg-secondary);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}