/**
 * Network Diagrams Styles
 * Styles for diagram list view, editor overlay, toolbar, canvas, and properties panel
 * (c) Adrian Ranta. All rights reserved. Unauthorised use, reproduction and or distribution is strictly prohibited.
 */

/* ========================================
   LIST VIEW - Diagram Cards Grid
   ======================================== */

.diagram-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 16px 0;
}

.diagram-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    position: relative;
}

.diagram-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.diagram-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.diagram-card-name {
    font-weight: 600;
    font-size: 15px;
    color: #1a1a2e;
    margin: 0;
    line-height: 1.3;
}

.diagram-card-account {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 8px;
}

.diagram-card-description {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.diagram-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #94a3b8;
}

.diagram-card-nodes {
    display: flex;
    align-items: center;
    gap: 4px;
}

.diagram-card-date {
    font-size: 12px;
    color: #94a3b8;
}

/* Status badges */
.status-draft {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    background: #FFF3E0;
    color: #E65100;
}

.status-published {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    background: #E8F5E9;
    color: #2E7D32;
}

.status-archived {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    background: #ECEFF1;
    color: #546E7A;
}

/* No diagrams message */
.no-diagrams {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.no-diagrams-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #64748b;
}

.no-diagrams-message {
    font-size: 14px;
}

/* ========================================
   DIAGRAM EDITOR OVERLAY
   ======================================== */

#diagramEditorView {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5000;
    background: white;
    flex-direction: column;
}

/* Toolbar */
.diagram-toolbar {
    height: auto;
    min-height: 48px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 4px 12px;
    background: #1a1a2e;
    border-bottom: 1px solid #2d2d4e;
    color: white;
}

.diagram-toolbar .btn {
    padding: 4px 12px;
    font-size: 13px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease;
}

.diagram-toolbar .btn-primary {
    background: #667eea;
    color: white;
    border-color: #5a6fd6;
}

.diagram-toolbar .btn-primary:hover {
    background: #5a6fd6;
}

.diagram-toolbar .btn-secondary {
    background: #4a4a6a;
    color: white;
    border-color: #5a5a7a;
}

.diagram-toolbar .btn-secondary:hover {
    background: #5a5a7a;
}

.diagram-toolbar .btn-danger {
    background: #ef4444;
    color: white;
    border-color: #dc2626;
}

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

.diagram-toolbar .btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.diagram-toolbar .btn:not(.btn-primary):not(.btn-secondary):not(.btn-danger):not(.active-mode) {
    background: #333355;
    color: #ccc;
    border-color: #444466;
}

.diagram-toolbar .btn:not(.btn-primary):not(.btn-secondary):not(.btn-danger):not(.active-mode):hover {
    background: #444466;
    color: white;
}

.diagram-toolbar .btn.active-mode {
    background: #667eea;
    color: white;
    border-color: #5a6fd6;
}

.toolbar-separator {
    width: 1px;
    height: 28px;
    background: #444466;
    margin: 0 4px;
}

/* Right-click context menu */
.diagram-context-menu {
    position: fixed;
    z-index: 6000;
    background: #2a2a4a;
    border: 1px solid #444466;
    border-radius: 6px;
    padding: 4px 0;
    min-width: 140px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.diagram-context-menu-item {
    padding: 8px 16px;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 13px;
}

.diagram-context-menu-item:hover {
    background: #3a3a5c;
}

.diagram-context-menu-danger {
    color: #ef5350;
}

.diagram-context-menu-danger:hover {
    background: #4a2020;
}

.diagram-title-display {
    margin-left: auto;
    font-size: 14px;
    font-weight: 500;
    color: #ccc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 250px;
}

/* Node Palette */
.node-palette {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
}

.node-palette-btn {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s ease, box-shadow 0.15s ease;
    color: #1a1a2e;
    font-weight: 600;
}

.node-palette-btn:hover {
    opacity: 0.85;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.node-palette-btn.palette-active {
    box-shadow: 0 0 0 2px #667eea;
    opacity: 1;
}

/* Editor Body */
.diagram-editor-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.diagram-canvas {
    flex: 1;
    position: relative;
    background: #f8f9fa;
}

.diagram-canvas canvas {
    width: 100%;
    height: 100%;
}

/* Properties Panel -- permanently hidden, replaced by node edit modal */
.diagram-properties-panel {
    display: none;
}

/* ========================================
   NODE EDIT MODAL (Fix 157)
   ======================================== */

.node-edit-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6100;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.node-edit-modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.node-edit-modal h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a2e;
}

.node-edit-modal .form-group {
    margin-bottom: 16px;
}

.node-edit-modal .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    margin-bottom: 4px;
}

.node-edit-modal .form-group input,
.node-edit-modal .form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    font-family: inherit;
}

.node-edit-modal .form-group input:focus,
.node-edit-modal .form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.node-edit-modal .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.node-edit-modal .form-actions .btn {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
}

.node-edit-modal .form-actions .btn-primary {
    background: #667eea;
    color: white;
    border-color: #5a6fd6;
}

.node-edit-modal .form-actions .btn-primary:hover {
    background: #5a6fd6;
}

.node-edit-modal .form-actions .btn-cancel {
    background: #f1f5f9;
    color: #334155;
    border-color: #e2e8f0;
}

.node-edit-modal .form-actions .btn-cancel:hover {
    background: #e2e8f0;
}

/* ========================================
   CONNECTION TYPE PICKER
   ======================================== */

.connection-type-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5100;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.connection-type-picker {
    background: white;
    border-radius: 8px;
    padding: 16px;
    min-width: 220px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.connection-type-picker h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
}

.connection-type-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
    border: none;
    background: none;
    width: 100%;
    font-size: 13px;
    color: #334155;
    text-align: left;
}

.connection-type-option:hover {
    background: #f1f5f9;
}

.connection-type-swatch {
    width: 24px;
    height: 3px;
    border-radius: 2px;
}

/* ========================================
   FORM MODAL (Create/Edit Diagram Metadata)
   ======================================== */

.diagram-form-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5200;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.diagram-form-modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.diagram-form-modal h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a2e;
}

.diagram-form-group {
    margin-bottom: 16px;
}

.diagram-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    margin-bottom: 4px;
}

.diagram-form-group input,
.diagram-form-group textarea,
.diagram-form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    font-family: inherit;
}

.diagram-form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.diagram-form-group input:focus,
.diagram-form-group textarea:focus,
.diagram-form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.diagram-form-error {
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
}

.diagram-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.diagram-form-actions .btn {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
}

.diagram-form-actions .btn-primary {
    background: #667eea;
    color: white;
    border-color: #5a6fd6;
}

.diagram-form-actions .btn-primary:hover {
    background: #5a6fd6;
}

.diagram-form-actions .btn-cancel {
    background: #f1f5f9;
    color: #334155;
    border-color: #e2e8f0;
}

.diagram-form-actions .btn-cancel:hover {
    background: #e2e8f0;
}

/* ========================================
   CONTEXT MENU
   ======================================== */

.diagram-context-menu {
    position: fixed;
    z-index: 5300;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    min-width: 160px;
}

.diagram-context-menu-item {
    padding: 8px 16px;
    font-size: 13px;
    color: #334155;
    cursor: pointer;
    transition: background 0.15s ease;
}

.diagram-context-menu-item:hover {
    background: #f1f5f9;
}

.diagram-context-menu-item.danger {
    color: #ef4444;
}

.diagram-context-menu-item.danger:hover {
    background: #fef2f2;
}

/* ========================================
   SAVED INDICATOR
   ======================================== */

.diagram-saved-indicator {
    position: fixed;
    top: 56px;
    right: 16px;
    background: #22c55e;
    color: white;
    padding: 6px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    z-index: 5050;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.diagram-saved-indicator.visible {
    opacity: 1;
}

/* Placement mode cursor */
/* Cursor is managed via JS on the vis.js canvas element directly */
