/* NovelBase Shared Modal Styles */
/* Version 1.0 - January 2026 */

/* ============================================
   MODAL OVERLAY & CONTAINER
   ============================================ */

.nb-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
}

.nb-modal-overlay.visible {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
}

.nb-modal {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Modal size variants */
.nb-modal.small {
    max-width: 400px;
}

.nb-modal.medium {
    max-width: 600px;
}

.nb-modal.large {
    max-width: 800px;
}

.nb-modal.xlarge {
    max-width: 1000px;
}

/* ============================================
   MODAL HEADER
   ============================================ */

.nb-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.nb-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1B2845;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nb-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.nb-modal-close:hover {
    background: #e0e0e0;
    color: #333;
}

/* ============================================
   AUTOSAVE STATUS
   ============================================ */

.nb-autosave-status {
    font-size: 0.85rem;
    font-weight: normal;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.nb-autosave-status.saving {
    color: #856404;
    background: #fff3cd;
}

.nb-autosave-status.saved {
    color: #155724;
    background: #d4edda;
}

.nb-autosave-status.error {
    color: #721c24;
    background: #f8d7da;
}

/* ============================================
   MODAL BODY
   ============================================ */

.nb-modal-body {
    padding: 1.5rem;
}

/* Section titles within modal */
.nb-section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1B2845;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 1.5rem 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #1B2845;
}

.nb-section-title:first-child {
    margin-top: 0;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */

.nb-form-row {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.nb-form-row.two-col {
    grid-template-columns: 1fr 1fr;
}

.nb-form-row.three-col {
    grid-template-columns: 1fr 1fr 1fr;
}

.nb-form-row.four-col {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

@media (max-width: 768px) {
    .nb-form-row.two-col,
    .nb-form-row.three-col,
    .nb-form-row.four-col {
        grid-template-columns: 1fr;
    }
}

.nb-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nb-form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #555;
}

.nb-form-group input[type="text"],
.nb-form-group input[type="number"],
.nb-form-group input[type="date"],
.nb-form-group input[type="email"],
.nb-form-group select,
.nb-form-group textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.nb-form-group input:focus,
.nb-form-group select:focus,
.nb-form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

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

.nb-form-group input[type="text"]:read-only,
.nb-form-group textarea:read-only {
    background: #f5f5f5;
    color: #666;
}

/* Placeholder styling */
.nb-form-group input::placeholder,
.nb-form-group textarea::placeholder {
    color: #999;
    font-style: italic;
}

/* ============================================
   MODAL FOOTER
   ============================================ */

.nb-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.nb-modal-footer-left {
    display: flex;
    gap: 0.5rem;
}

.nb-modal-footer-right {
    display: flex;
    gap: 0.5rem;
}

/* ============================================
   BUTTONS
   ============================================ */

.nb-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.nb-btn:active {
    transform: scale(0.98);
}

.nb-btn-primary {
    background: #3498db;
    color: #fff;
}

.nb-btn-primary:hover {
    background: #2980b9;
}

.nb-btn-secondary {
    background: #95a5a6;
    color: #fff;
}

.nb-btn-secondary:hover {
    background: #7f8c8d;
}

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

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

.nb-btn-danger:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.nb-btn-link {
    background: none;
    color: #3498db;
    padding: 0.5rem;
}

.nb-btn-link:hover {
    text-decoration: underline;
}

/* ============================================
   NOTICES & ALERTS
   ============================================ */

.nb-notice {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.nb-notice-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.nb-notice-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.nb-notice-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.nb-notice-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* ============================================
   LOADING STATE
   ============================================ */

.nb-modal-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    color: #666;
}

.nb-modal-loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid #e0e0e0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: nb-spin 0.8s linear infinite;
    margin-left: 0.75rem;
}

@keyframes nb-spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   HELPER CLASSES
   ============================================ */

.nb-text-muted {
    color: #666;
    font-size: 0.85rem;
}

.nb-text-small {
    font-size: 0.85rem;
}

.nb-mt-1 { margin-top: 0.5rem; }
.nb-mt-2 { margin-top: 1rem; }
.nb-mt-3 { margin-top: 1.5rem; }
.nb-mb-1 { margin-bottom: 0.5rem; }
.nb-mb-2 { margin-bottom: 1rem; }
.nb-mb-3 { margin-bottom: 1.5rem; }

.nb-hidden {
    display: none !important;
}

/* ============================================
   MINDMAP MODAL STYLES
   ============================================ */

.nb-modal-xlarge {
    max-width: 1100px;
}

.mindmap-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #f8f8f8;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
    gap: 10px;
}

.mindmap-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.mindmap-filter-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background: #fff;
    color: #1B2845;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.mindmap-filter-btn:hover {
    background: #e8e8e8;
}

.mindmap-filter-btn.active {
    background: #1B2845;
    color: #fff;
}

.mindmap-legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 11px;
    color: #666;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.mindmap-container {
    display: flex;
    min-height: 400px;
}

.mindmap-graph {
    flex: 1;
    background: #fff;
    position: relative;
    overflow: hidden;
}

.mindmap-loading,
.mindmap-empty,
.mindmap-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 14px;
}

.mindmap-error {
    color: #c62828;
}

.mindmap-details {
    width: 240px;
    border-left: 1px solid #e0e0e0;
    background: #fafafa;
    overflow-y: auto;
    padding: 12px;
}

.details-empty {
    text-align: center;
    color: #999;
    padding: 30px 10px;
    font-size: 13px;
}

.details-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 12px;
}

.details-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.details-title {
    min-width: 0;
}

.details-name {
    font-weight: 600;
    color: #1B2845;
    font-size: 14px;
    word-break: break-word;
}

.details-type {
    font-size: 11px;
    color: #666;
    text-transform: capitalize;
}

.details-section-title {
    font-weight: 600;
    font-size: 12px;
    color: #1B2845;
    margin-bottom: 8px;
}

.details-connection {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: #fff;
    border-radius: 4px;
    margin-bottom: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s;
}

.details-connection:hover {
    background: #e8e8e8;
}

.conn-icon {
    flex-shrink: 0;
}

.conn-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conn-rel {
    font-size: 10px;
    color: #999;
    flex-shrink: 0;
}

.details-empty-connections {
    color: #999;
    font-size: 12px;
    font-style: italic;
}

.mindmap-footer {
    padding: 8px 16px;
    background: #f8f8f8;
    border-top: 1px solid #e0e0e0;
    font-size: 11px;
    color: #666;
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .mindmap-details {
        width: 180px;
    }
    
    .mindmap-legend {
        display: none;
    }
}
