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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
}

/* Tab Navigation */
.tab-container {
    background: white;
    border-bottom: 2px solid #ddd;
    display: flex;
    padding: 0 20px;
}

.tab {
    padding: 15px 30px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    font-weight: 500;
    transition: all 0.3s;
}

.tab:hover {
    background: #f8f9fa;
}

.tab.active {
    border-bottom-color: #4a90e2;
    color: #4a90e2;
}

/* Toolbar */
.toolbar {
    background: white;
    padding: 15px 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.toolbar label {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.toolbar label:hover {
    background: #e9ecef;
}

.toolbar input[type="checkbox"] {
    cursor: pointer;
}

.zoom-indicator {
    margin-left: auto;
    padding: 5px 10px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
    cursor: help;
}

.toolbar-btn {
    padding: 8px 16px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.toolbar-btn:hover {
    background: #e9ecef;
}

.toolbar-btn.primary {
    background: #4a90e2;
    color: white;
    border-color: #4a90e2;
}

.toolbar-btn.primary:hover {
    background: #357abd;
}

.toolbar-btn.danger {
    background: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

.toolbar-btn.danger:hover {
    background: #c0392b;
}

/* Canvas Container */
.view-container {
    display: none;
    width: 100%;
    height: calc(100vh - 120px);
    position: relative;
}

.view-container.active {
    display: block;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #f0f0f0;
    cursor: default;
}

.canvas-wrapper.panning {
    cursor: grabbing;
}

.canvas-content {
    transform-origin: 0 0;
    position: relative;
    will-change: transform;
}

.grid-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    background-image: 
        linear-gradient(rgba(0,0,0,.12) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,.12) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: 0;
}

#canvas-entities,
#canvas-database,
#canvas-laravel {
    background: white;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Entity/Table/Model Box */
.entity {
    position: absolute;
    background: white;
    border: 2px solid #333;
    border-radius: 8px;
    min-width: 250px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    user-select: none;
    cursor: move;
    z-index: 10;
}

.entity.selected {
    border-color: #4a90e2;
    box-shadow: 0 4px 16px rgba(74, 144, 226, 0.3);
}

.entity-header {
    background: #f8f9fa;
    padding: 12px 16px;
    border-bottom: 1px solid #ddd;
    border-radius: 6px 6px 0 0;
    font-weight: bold;
    font-size: 16px;
    position: relative;
    cursor: help;
}

.entity-header:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

.entity-connection-point {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 3px solid #e74c3c;
    cursor: crosshair;
    transition: all 0.2s ease;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.entity-connection-point.left {
    left: -10px;
}

.entity-connection-point.right {
    right: -10px;
}

.entity-connection-point:hover {
    transform: translateY(-50%) scale(1.2);
    border-color: #c0392b;
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.4);
}

/* Attribute Row */
.attribute-row {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid #eee;
    position: relative;
}

.attribute-row:last-child {
    border-bottom: none;
}

.attribute-row.selected {
    background: #e3f2fd;
}

.attribute-checkbox {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    cursor: pointer;
}

.attribute-name {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.attribute-type {
    font-size: 13px;
    color: #666;
    margin-left: 10px;
}

.attribute-properties {
    font-size: 12px;
    color: #999;
    margin-left: 10px;
    font-weight: bold;
}

.field-connection-point {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    border: 2px solid #e74c3c;
    cursor: crosshair;
    transition: all 0.2s ease;
    top: 50%;
    transform: translateY(-50%);
}

.field-connection-point.left {
    left: -6px;
}

.field-connection-point.right {
    right: -6px;
}

.field-connection-point:hover {
    transform: translateY(-50%) scale(1.3);
    border-color: #c0392b;
}

/* Laravel Relation Row */
.relation-row {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid #eee;
    position: relative;
}

.relation-row:last-child {
    border-bottom: none;
}

.relation-row.selected {
    background: #e3f2fd;
}

.relation-checkbox {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    cursor: pointer;
}

.relation-name {
    flex: 1;
    font-size: 14px;
    color: #333;
    font-style: italic;
}

.relation-type {
    font-size: 13px;
    color: #e74c3c;
    margin-left: 10px;
    font-weight: 500;
}

.relation-target {
    font-size: 12px;
    color: #666;
    margin-left: 10px;
}

.relation-connection-point {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    border: 2px solid #4a90e2;
    cursor: crosshair;
    transition: all 0.2s ease;
    top: 50%;
    transform: translateY(-50%);
}

.relation-connection-point.left {
    left: -6px;
}

.relation-connection-point.right {
    right: -6px;
}

.relation-connection-point:hover {
    transform: translateY(-50%) scale(1.3);
    border-color: #357abd;
}

/* Connection Lines */
.connection-line {
    stroke: #4a90e2;
    stroke-width: 2.5;
    fill: none;
    cursor: pointer;
    transition: stroke-width 0.2s, stroke 0.2s;
}

.connection-line:hover {
    stroke: #c2410c;
    stroke-width: 3.5;
}

.connection-arrow {
    fill: #4a90e2;
    transition: fill 0.2s;
}

.connection-arrow.active-hover {
    fill: #c2410c;
}

.connection-line.selected {
    stroke: #e74c3c;
    stroke-width: 3.5;
}

.temp-connection {
    stroke: #4a90e2;
    stroke-width: 2.5;
    stroke-dasharray: 8, 4;
    fill: none;
    pointer-events: none;
    opacity: 0.7;
}

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

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.modal-header {
    background: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid #ddd;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

.close {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #000;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group textarea {
    min-height: 200px;
    font-family: monospace;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.btn-primary {
    background: #4a90e2;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

/* Laravel Workspace Styles */
.laravel-workspace {
    display: flex;
    height: calc(100vh - 160px);
    background: #1e1e1e;
    position: relative;
}

.files-panel {
    width: 300px;
    min-width: 200px;
    background: #252526;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.resize-handle {
    width: 4px;
    background: #3e3e42;
    cursor: col-resize;
    flex-shrink: 0;
    position: relative;
    transition: background 0.2s;
}

.resize-handle:hover {
    background: #007acc;
}

.resize-handle:active {
    background: #007acc;
}

.files-header {
    padding: 8px 12px;
    background: #2d2d30;
    border-bottom: 1px solid #3e3e42;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.files-header h4 {
    color: #cccccc;
    font-size: 11px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.files-actions {
    display: flex;
    gap: 4px;
}

.btn-icon {
    background: none;
    border: none;
    color: #cccccc;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
    font-size: 10px;
}

.btn-icon:hover {
    background: #3e3e42;
}

.files-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    color: #cccccc;
}

.empty-state {
    padding: 20px;
    text-align: center;
    color: #858585;
    font-size: 13px;
}

.file-item, .folder-item {
    display: flex;
    align-items: center;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    user-select: none;
}

.file-item:hover, .folder-item:hover {
    background: #2a2d2e;
}

.file-item.selected {
    background: #094771;
}

.folder-item.expanded {
    background: #2a2d2e;
}

.file-checkbox {
    margin-right: 6px;
    width: 12px;
    height: 12px;
}

.folder-toggle {
    margin-right: 4px;
    font-size: 10px;
    color: #cccccc;
    transition: transform 0.2s;
}

.folder-toggle.expanded {
    transform: rotate(90deg);
}

.file-icon, .folder-icon {
    margin-right: 6px;
    font-size: 12px;
}

.folder-icon {
    color: #dcb67a;
}

.file-icon.php { color: #8892be; }
.file-icon.js { color: #f7df1e; }
.file-icon.css { color: #42a5f5; }
.file-icon.html { color: #e34c26; }
.file-icon.json { color: #90cdf4; }
.file-icon.md { color: #81c784; }

.folder-children {
    margin-left: 16px;
}

.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
}

.editor-tabs {
    background: #2d2d30;
    border-bottom: 1px solid #3e3e42;
    display: flex;
    align-items: center;
    min-height: 32px;
    overflow-x: auto;
}

.tab-placeholder {
    padding: 8px 16px;
    color: #858585;
    font-size: 13px;
}

.editor-tab {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #2d2d30;
    border-right: 1px solid #3e3e42;
    color: #cccccc;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    max-width: 200px;
    min-width: 100px;
    /* Long file names must truncate INSIDE the tab — without this the
       name span overflows the max-width and pushes the × out of view. */
    overflow: hidden;
    flex-shrink: 0;
}

.editor-tab .tab-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.editor-tab.active {
    background: #1e1e1e;
    border-bottom: 1px solid #1e1e1e;
}

.editor-tab:hover {
    background: #323233;
}

.editor-tab.active:hover {
    background: #1e1e1e;
}

.tab-close {
    margin-left: 8px;
    color: #858585;
    cursor: pointer;
    padding: 0 2px;
    flex: 0 0 auto;
}

.tab-close:hover {
    color: #cccccc;
}

.editor-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.editor-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #1e1e1e;
}

.placeholder-content {
    text-align: center;
    color: #858585;
}

.placeholder-content h3 {
    color: #cccccc;
    margin-bottom: 16px;
    font-weight: 300;
}

.placeholder-content p {
    margin-bottom: 8px;
    line-height: 1.5;
}

.CodeMirror {
    height: 100% !important;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.4;
}

.CodeMirror-scroll {
    height: 100%;
}

.generation-status {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #2d2d30;
    color: #cccccc;
    padding: 20px 30px;
    border-radius: 6px;
    border: 1px solid #3e3e42;
    z-index: 10000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.generation-progress {
    margin-top: 10px;
}

.progress-bar {
    width: 200px;
    height: 4px;
    background: #3e3e42;
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #007acc;
    transition: width 0.3s ease;
}

/* Tooltips */
.global-tooltip {
    position: fixed;
    background-color: #333;
    color: #fff;
    text-align: left;
    padding: 8px 12px;
    border-radius: 6px;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    font-size: 13px;
    font-weight: normal;
    white-space: normal;
    max-width: 300px;
    line-height: 1.4;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transform: translate(-50%, 0);
}

.has-tooltip {
    cursor: help;
    position: relative;
}

.entity-header.has-tooltip {
    cursor: help;
}

.attribute-name {
    flex: 1;
    font-size: 14px;
    color: #333;
    position: relative;
}

.attribute-name.has-tooltip {
    cursor: help;
}

/* Keep old connection tooltip for SVG paths */
.tooltip.connection-tooltip {
    position: fixed;
    background-color: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    z-index: 2000;
    font-size: 13px;
    white-space: normal;
    max-width: 300px;
    line-height: 1.4;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transform: translate(-50%, -100%);
    margin-top: -10px;
}

.pq-grid {
    border: none !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
    font-size: 11px !important;
}
