/* Modern Life Planning Application - Clean & Intuitive Design */

/* CSS Variables for consistent theming */
:root {
    /* Modern Color Palette */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-header: #f8fafc;
    --bg-hover: #f1f5f9;
    --bg-active: #e2e8f0;
    
    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;
    
    /* Border Colors */
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    --border-dark: #94a3b8;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    
    /* Z-index layers */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal: 1050;
    --z-tooltip: 1070;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-family);
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Canvas Container */
#canvas-container {
    position: relative;
    width: 100%;
    height: 100vh;
    background: var(--bg-primary);
    overflow: hidden;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: default;
    background: var(--bg-primary);
    border: none;
}

/* Main Application Layout */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Panels */
.sidebar {
    position: relative;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: width var(--transition-normal);
    overflow: hidden;
}

.sidebar.left {
    width: 60px;
    min-width: 60px;
}

.sidebar.left.expanded {
    width: 280px;
}

.sidebar.right {
    width: 60px;
    min-width: 60px;
    border-right: none;
    border-left: 1px solid var(--border-light);
}

.sidebar.right.expanded {
    width: 320px;
}

/* Panel Headers */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-light);
    min-height: 60px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.panel-header:hover {
    background: var(--bg-hover);
}

.panel-header.collapsed {
    justify-content: center;
    padding: var(--space-2);
    min-height: 60px;
}

.panel-title {
    font-weight: 600;
    font-size: var(--font-size-base);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.panel-header.collapsed .panel-title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-size: var(--font-size-sm);
    color: var(--text-inverse);
}

.panel-controls {
    display: flex;
    gap: var(--space-1);
    align-items: center;
}

.panel-header.collapsed .panel-controls {
    display: none;
}

/* Control Buttons */
.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.control-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-medium);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.control-btn:active {
    transform: translateY(0);
    background: var(--bg-active);
}

.control-btn.primary {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

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

/* Panel Content */
.panel-content {
    padding: var(--space-4);
    height: calc(100vh - 60px);
    overflow-y: auto;
    background: var(--bg-panel);
}

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

.panel-content::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.panel-content::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--border-dark);
}

/* Toolbar */
.toolbar {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.tool-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: var(--bg-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
}

.tool-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left var(--transition-normal);
}

.tool-item:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tool-item:hover::before {
    left: 100%;
}

.tool-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: var(--text-inverse);
    border-color: var(--primary-hover);
    box-shadow: var(--shadow-lg);
}

.tool-item.collapsed {
    justify-content: center;
    padding: var(--space-3);
    min-width: 44px;
    width: 44px;
}

.tool-item.collapsed .tool-label {
    display: none;
}

.tool-icon {
    font-size: var(--font-size-lg);
    min-width: 20px;
    text-align: center;
}

.tool-label {
    font-weight: 500;
    white-space: nowrap;
}

/* Form Elements */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: 500;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

.form-input:hover {
    border-color: var(--border-medium);
}

.form-input[type="color"] {
    height: 40px;
    padding: var(--space-1);
    cursor: pointer;
    border-radius: var(--radius-lg);
}

.form-input[type="color"]:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.form-button {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: var(--text-inverse);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
}

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

.form-button:active {
    transform: translateY(0);
}

/* Zoom Controls */
.zoom-controls {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-fixed);
    display: flex;
    gap: var(--space-2);
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: var(--space-2);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
}

.zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.zoom-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.zoom-display {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    padding: 0 var(--space-3);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

/* Mouse Position Display */
.mouse-position {
    position: fixed;
    bottom: var(--space-6);
    left: var(--space-6);
    background: var(--bg-panel);
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    z-index: var(--z-fixed);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(8px);
    font-weight: 500;
}

/* Context Menu */
.context-menu {
    position: absolute;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-modal);
    padding: var(--space-2);
    min-width: 200px;
    backdrop-filter: blur(8px);
    display: none;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    font-weight: 500;
}

.context-menu-item:hover {
    background: var(--bg-hover);
    transform: translateX(4px);
    color: var(--primary);
}

.context-menu-item:last-child {
    margin-bottom: 0;
}

/* Draggable Panels */
.draggable {
    cursor: move;
}

.draggable:hover {
    background: var(--bg-hover);
}

/* Collapsed State */
.collapsed .panel-content {
    display: none;
}

.collapsed .panel-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: var(--text-inverse);
    border-radius: var(--radius-lg);
    margin: var(--space-2);
    min-height: 44px;
}

.collapsed .panel-header:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary) 100%);
    transform: scale(1.05);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        z-index: var(--z-modal);
        transform: translateX(-100%);
        transition: transform var(--transition-slow);
    }
    
    .sidebar.left {
        left: 0;
        width: 280px;
    }
    
    .sidebar.right {
        right: 0;
        width: 320px;
        transform: translateX(100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .zoom-controls {
        top: auto;
        bottom: var(--space-6);
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
    
    .mouse-position {
        display: none;
    }
    
    .context-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    }
}

/* Performance Optimizations */
* {
    will-change: auto;
}

.canvas-container {
    contain: layout style paint;
}

.panel-content {
    contain: layout style;
}

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

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.panel-content {
    animation: fadeIn var(--transition-normal) ease-out;
}

.sidebar.open {
    animation: slideIn var(--transition-slow) ease-out;
}

/* Focus States for Accessibility */
.control-btn:focus,
.tool-item:focus,
.form-input:focus,
.form-button:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Form Layout */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

.properties-section {
    margin-bottom: var(--space-8);
}

.section-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--border-light);
}

.group-list,
.category-list {
    list-style: none;
    padding: 0;
    margin: var(--space-2) 0;
}

.group-list li,
.category-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-1);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    border-left: 3px solid var(--primary);
}

.group-list li:last-child,
.category-list li:last-child {
    margin-bottom: 0;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border-light);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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