/* Glass Optimizer - Main Styles */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --danger-surface: #fef2f2;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--primary);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px var(--shadow);
}

.header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

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

.header nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.header nav a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.header nav a.active {
    background: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

/* Language Selector */
.language-selector {
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lang-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Welcome Section */
.welcome-section {
    text-align: center;
    margin-bottom: 3rem;
}

.welcome-section h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.welcome-section p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.action-card {
    background: var(--surface);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--shadow);
    text-decoration: none;
    color: var(--text);
    transition:
        transform 0.2s,
        box-shadow 0.2s;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px var(--shadow);
}

.action-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--shadow);
    text-align: center;
}

.stat-card h4 {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

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

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

/* Designer Layout */
.designer-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
    flex: 1;
}

.sidebar {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--shadow);
    height: fit-content;
}

.sidebar h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.tool-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.tool-btn {
    padding: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}

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

.tool-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 600;
}

.properties {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.properties label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.properties input[type="number"] {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
}

/* Holes List */
.holes-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.hole-item {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    transition: all 0.2s;
}

.hole-item.selected {
    border-color: var(--warning);
    background: #fffbeb;
}

.hole-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.hole-item-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
}

.hole-item-delete {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
    line-height: 1;
}

.hole-item-delete:hover {
    opacity: 0.7;
}

.hole-item-props {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hole-item-props label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.hole-item-props input {
    padding: 0.375rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
    width: 100%;
}

/* Canvas Area */
.canvas-area {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--shadow);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.canvas-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#design-canvas {
    border: 2px solid var(--border);
    border-radius: 4px;
    background: white;
    display: block;
    /* IMPORTANT: No CSS width/height - causes coordinate mismatch */
    /* Canvas pixel dimensions set by JavaScript setupCanvas() */
    max-width: 100%;
    height: auto;
}

/* Mobile canvas responsiveness */
@media (max-width: 768px) {
    #design-canvas {
        width: 100% !important;
        max-width: calc(100vw - 40px) !important;
        height: auto !important;
        margin: 0 auto !important;
        display: block !important;
    }

    .canvas-area {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    .designer-layout {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    .container {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
}

.canvas-info {
    margin-top: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Optimizer Layout */
.optimizer-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    flex: 1;
}

.optimizer-main {
    display: flex;
    flex-direction: column;
}

.optimizer-toolbar {
    margin-bottom: 1.5rem;
}

.design-list,
.sheet-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.design-item,
.sheet-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.design-item:hover,
.sheet-item:hover {
    background: #e0f2fe;
    border-color: var(--primary);
}

.design-item input,
.sheet-item input {
    cursor: pointer;
}

select {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

.full-width {
    width: 100%;
}

/* Results Area */
.results-area {
    background: var(--surface);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--shadow);
}

.results-area h3 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.visualization {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 4px;
    padding: 3rem;
    text-align: center;
    color: var(--text-secondary);
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-message {
    background: var(--surface);
    padding: 3rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--shadow);
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Footer */
.footer {
    background: var(--surface);
    padding: 1.5rem 2rem;
    text-align: center;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* Print Styles */
@page {
    margin: 0.5cm;
    size: landscape;
}

@media print {
    * {
        box-sizing: border-box;
    }

    html,
    body {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    /* Hide all main content */
    .container > .header,
    .container > main,
    .container > .footer {
        display: none !important;
    }

    /* Print template styles */
    .print-template {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        margin: 0;
        padding: 1rem;
        box-sizing: border-box;
        background: white;
        z-index: 9999;
    }

    .print-header {
        border-bottom: 2px solid #000;
        padding-bottom: 0.4rem;
        margin-bottom: 0.6rem;
    }

    .print-header h1 {
        font-size: 1.1rem;
        margin: 0 0 0.2rem 0;
    }

    .print-header p {
        font-size: 0.7rem;
        color: #64748b;
        margin: 0;
    }

    .print-content {
        display: grid;
        grid-template-columns: 75% 23%;
        gap: 2%;
        height: calc(100vh - 4rem);
        align-items: stretch;
    }

    .print-drawing-area {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
        padding: 0.5rem;
        overflow: hidden;
    }

    .print-drawing-area canvas {
        max-width: 100% !important;
        max-height: 100% !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain;
        display: block;
        margin: 0 auto;
        border: 2px solid #000;
    }

    .print-specs-area {
        display: flex;
        flex-direction: column;
        max-height: calc(100vh - 5rem);
        overflow-y: auto;
        padding: 0.5rem 0.75rem;
    }

    .print-specs-area h3 {
        font-size: 0.85rem;
        margin: 0 0 0.4rem 0;
        border-bottom: 1px solid #000;
        padding-bottom: 0.2rem;
    }

    .print-property {
        display: flex;
        justify-content: space-between;
        padding: 0.2rem 0;
        border-bottom: 1px solid #e2e8f0;
        font-size: 0.75rem;
        line-height: 1.4;
    }

    .print-property-label {
        font-weight: 600;
    }

    .print-hole-spec {
        margin-bottom: 0.4rem;
        padding: 0.35rem;
        border: 1px solid #000;
        border-radius: 4px;
    }

    .print-hole-type {
        font-weight: 600;
        margin-bottom: 0.2rem;
        font-size: 0.8rem;
    }

    /* Hide regular canvas during print */
    #design-canvas {
        display: none !important;
    }

    /* Show only print canvas */
    #print-canvas {
        display: block !important;
        max-width: 100%;
        border: 2px solid #000;
    }
}

/* Hide print template on screen */
.print-template {
    display: none;
}

/* Projects Section */
.projects-section {
    margin-top: 3rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.75rem;
    color: var(--text);
    margin: 0;
}

.btn-icon {
    font-size: 1.25rem;
    font-weight: bold;
    margin-right: 0.25rem;
}

.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
}

/* Projects Tree */
.projects-tree {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--shadow);
    padding: 1.5rem;
    min-height: 200px;
}

.tree-loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.project-node {
    margin-bottom: 0.75rem;
}

.project-item {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    transition: all 0.2s;
    cursor: pointer;
}

.project-item:hover {
    border-color: var(--primary);
    background: #f0f9ff;
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.project-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-icon {
    font-size: 1rem;
    color: var(--primary);
}

.project-actions {
    display: flex;
    gap: 0.5rem;
}

.project-btn {
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
    color: var(--text);
}

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

.project-btn.delete:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.project-meta {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.project-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.project-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.project-children {
    margin-left: 2rem;
    margin-top: 0.75rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border);
}

.no-projects {
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem;
    font-size: 1rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.modal-sm {
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 0;
    width: 2rem;
    height: 2rem;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-content form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text);
    font-size: 0.875rem;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.designs-placeholder {
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 1rem;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 4px;
    text-align: center;
    margin-bottom: 0.75rem;
}

#designs-list-container:not(:has(.designs-placeholder)) {
    margin-bottom: 0.75rem;
}

.design-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.design-list-item-info {
    flex: 1;
}

.design-list-item-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.design-list-item-meta {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.design-list-item-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.design-list-item-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.design-list-item-quantity label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.design-list-item-quantity input {
    width: 60px;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
}

.btn-remove {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--danger);
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

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

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 2rem;
    padding: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface-hover);
}

/* Design Picker */
.picker-list {
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.picker-loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.picker-item {
    padding: 0.875rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.picker-item:hover {
    background: #f0f9ff;
    border-color: var(--primary);
}

.picker-item-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.picker-item-meta {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Project Tree Selector */
.project-tree-selector {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem;
    background: var(--bg);
}

.tree-project-item {
    margin: 0.25rem 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface);
}

.tree-project-header {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    gap: 0.5rem;
}

.tree-project-content {
    flex: 1;
}

.tree-expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.tree-expand-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.tree-project-item.selected .tree-expand-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tree-expand-spacer {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.expand-icon {
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform 0.2s;
    user-select: none;
}

.tree-project-item.selected .expand-icon {
    color: rgba(255, 255, 255, 0.8);
}

.expand-icon.expanded {
    transform: rotate(90deg);
}

.tree-project-item:hover {
    background: #f0f9ff;
    border-color: var(--primary);
}

.tree-project-item.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tree-project-item.selected .tree-project-path {
    color: rgba(255, 255, 255, 0.8);
}

.tree-project-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.tree-project-path {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.tree-project-children {
    margin-left: 1.5rem;
    margin-top: 0.25rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--border);
}

.selected-project-path {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #f0f9ff;
    border: 1px solid var(--primary);
    border-radius: 4px;
    color: var(--text);
}

.modal-body {
    padding: 1.5rem;
}

/* Project Detail Page */
.breadcrumb {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.breadcrumb a,
.breadcrumb-link {
    color: var(--primary);
    text-decoration: none;
}

.breadcrumb a:hover,
.breadcrumb-link:hover {
    text-decoration: underline;
}

.breadcrumb-separator {
    margin: 0 0.5rem;
}

.breadcrumb-current {
    color: var(--text);
    font-weight: 600;
}

/* Project Tree Picker Styles */
.project-tree-picker {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 0.5rem;
    background: var(--surface);
}

/* Project Menu Styles - Completely Redesigned */
.project-dropdown {
    position: relative;
    display: inline-block;
}

.project-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.375rem 0.5rem;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.project-menu-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.menu-dots {
    user-select: none;
    font-weight: bold;
    transform: rotate(90deg);
}

/* Desktop Menu */
.project-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 1000;
    min-width: 140px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}

.project-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-item {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
}

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

.menu-item:hover {
    background: var(--surface-hover);
}

.menu-item.delete {
    color: var(--danger);
}

.menu-item.delete:hover {
    background: var(--danger-surface);
}

/* Mobile Menu Override */
@media (max-width: 768px) {
    .project-menu {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        min-width: 280px;
        max-width: 320px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        padding: 1rem;
        background: var(--surface);
        border: 2px solid var(--border);
        border-radius: 8px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        z-index: 9999;
    }

    .project-menu.active {
        opacity: 1;
        visibility: visible;
        transform: translate(-50%, -50%);
    }

    .project-menu::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
        pointer-events: none;
    }

    .menu-item {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 48px;
        padding: 0.75rem 1rem;
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 6px;
        font-size: 0.875rem;
        font-weight: 500;
        text-align: center;
        cursor: pointer;
        transition: all 0.2s ease;
        box-sizing: border-box;
        white-space: nowrap;
    }

    .menu-item:hover {
        background: var(--surface-hover);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .menu-item.delete {
        grid-column: 1 / -1;
        background: var(--danger-surface);
        border-color: var(--danger);
        color: var(--danger);
    }

    .menu-item.delete:hover {
        background: var(--danger);
        color: white;
        transform: translateY(-1px);
    }
}

.project-tree-item {
    margin: 0.25rem 0;
}

.project-item {
    padding: 0.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-item.selectable:hover {
    background: var(--surface-hover);
}

.project-item.selected {
    background: var(--primary);
    color: white;
}

.project-item.disabled {
    background: var(--surface-muted);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

.project-name {
    flex: 1;
    font-weight: 500;
}

.current-project-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.project-item.disabled .current-project-label {
    color: var(--text-muted);
}

.project-detail-header {
    background: var(--surface);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--shadow);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
}

.project-detail-title-section {
    flex: 1;
}

.project-detail-title-section h2 {
    margin: 0 0 0.5rem 0;
    font-size: 2rem;
    color: var(--text);
}

.project-detail-description {
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

.project-detail-actions {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.project-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border);
}

.project-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
    margin-bottom: -2px;
}

.project-tab:hover {
    color: var(--primary);
}

.project-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.project-content-section {
    display: none;
}

.project-content-section.active {
    display: block;
}

.section-header-inline {
    margin-bottom: 1.5rem;
}

.section-header-inline h3 {
    font-size: 1.5rem;
    color: var(--text);
    margin: 0;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.content-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.2s;
    cursor: pointer;
}

.content-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px var(--shadow);
}

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

.content-card-header h4 {
    margin: 0;
    font-size: 1.125rem;
    color: var(--text);
}

.content-card-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.content-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.content-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Content Card Menu */
.content-card-menu {
    position: relative;
    z-index: 10;
}

.menu-trigger {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-trigger:hover {
    background: var(--border);
    color: var(--text);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--shadow);
    min-width: 160px;
    z-index: 100;
    padding: 0.5rem 0;
}

.dropdown-menu button {
    width: 100%;
    background: none;
    border: none;
    padding: 0.75rem 1rem;
    text-align: left;
    cursor: pointer;
    color: var(--text);
    font-size: 0.875rem;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-menu button:hover {
    background: var(--bg);
}

.dropdown-menu button:focus {
    outline: none;
    background: var(--bg);
}

/* Delete button specific styling */
.dropdown-menu button:hover:last-child {
    background: var(--danger-surface);
    color: var(--danger);
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

.empty-state p {
    margin-bottom: 1.5rem;
    font-size: 1.125rem;
}

.loading-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    grid-column: 1 / -1;
}

.error-message {
    text-align: center;
    color: var(--danger);
    padding: 2rem;
    grid-column: 1 / -1;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: var(--surface);
    color: var(--text);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    max-width: 500px;
    pointer-events: auto;
    cursor: pointer;
    border-left: 4px solid var(--primary);
    transition: all 0.3s ease;
}

.toast-icon {
    font-size: 1.25rem;
    font-weight: bold;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
}

.toast-message {
    flex: 1;
    font-size: 0.9375rem;
    line-height: 1.4;
}

/* Toast types */
.toast-success {
    border-left-color: var(--success);
}

.toast-success .toast-icon {
    color: var(--success);
}

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

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

.toast-warning {
    border-left-color: var(--warning);
}

.toast-warning .toast-icon {
    color: var(--warning);
}

.toast-info {
    border-left-color: var(--primary);
}

.toast-info .toast-icon {
    color: var(--primary);
}

/* Toast animations */
.toast-enter {
    opacity: 0;
    transform: translateX(100%);
}

.toast-show {
    opacity: 1;
    transform: translateX(0);
}

.toast-exit {
    opacity: 0;
    transform: translateX(100%);
}

/* Responsive */
@media (max-width: 768px) {
    .designer-layout,
    .optimizer-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        order: 2;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .project-children {
        margin-left: 1rem;
    }

    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .project-detail-header {
        flex-direction: column;
    }

    .project-detail-actions {
        width: 100%;
        flex-direction: column;
    }

    .project-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .content-grid {
        grid-template-columns: 1fr;
    }
}
