/* db_designer.css — modal for the user-friendly table designer */

.dbd-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.dbd-overlay.show { display: flex; }

.dbd-modal {
    background: #fff;
    width: min(820px, 96vw);
    max-height: 92vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dbd-header {
    background: #4f46e5;
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.dbd-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}
.dbd-header button.dbd-close {
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

.dbd-body {
    padding: 18px;
    overflow-y: auto;
    flex: 1;
}

.dbd-footer {
    border-top: 1px solid #e5e7eb;
    padding: 12px 18px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #f9fafb;
}

.dbd-btn {
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: #fff;
    font-size: 14px;
    cursor: pointer;
}
.dbd-btn.primary {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}
.dbd-btn.primary:hover { background: #4338ca; }
.dbd-btn.danger {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}
.dbd-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* List view */
.dbd-table-list { display: flex; flex-direction: column; gap: 10px; }
.dbd-table-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.dbd-table-card .name { font-weight: 600; color: #111827; }
.dbd-table-card .desc { color: #6b7280; font-size: 13px; margin-top: 2px; }
.dbd-table-card .meta { color: #9ca3af; font-size: 12px; margin-top: 4px; }
.dbd-empty { color: #6b7280; font-style: italic; padding: 20px 0; text-align: center; }

/* Designer view */
.dbd-section { margin-bottom: 14px; }
.dbd-section label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}
.dbd-input, .dbd-textarea, .dbd-select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
    box-sizing: border-box;
    font-family: inherit;
}
.dbd-textarea { min-height: 70px; resize: vertical; }

.dbd-fields-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}
.dbd-fields-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    padding: 6px 6px;
    border-bottom: 1px solid #e5e7eb;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.dbd-fields-table td {
    padding: 5px 6px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.dbd-fields-table input, .dbd-fields-table select {
    border: 1px solid #d1d5db;
    border-radius: 5px;
    padding: 5px 8px;
    font-size: 13px;
    box-sizing: border-box;
    font-family: inherit;
    width: 100%;
}
.dbd-fields-table .col-len input { width: 70px; }
.dbd-fields-table .col-rm button {
    background: transparent;
    border: 0;
    color: #ef4444;
    cursor: pointer;
    padding: 4px 6px;
    font-size: 14px;
}
.dbd-row-system td {
    color: #9ca3af;
    font-style: italic;
    background: #fafafa;
}
.dbd-row-actions { white-space: nowrap; }
.dbd-row-actions .dbd-btn { padding: 4px 8px; font-size: 12px; }

/* Row-edit modal — opens above the main designer modal so users get
   one field per line with full width. Higher z-index than .dbd-overlay. */
.dbd-row-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}
.dbd-row-modal {
    background: #fff;
    width: min(560px, 94vw);
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.dbd-row-modal-header {
    background: #4f46e5;
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.dbd-row-modal-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.dbd-row-modal-close {
    background: transparent; border: 0; color: #fff; font-size: 22px; cursor: pointer; line-height: 1;
}
.dbd-row-modal-body {
    padding: 16px 18px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.dbd-row-field { display: flex; flex-direction: column; gap: 4px; }
.dbd-row-field label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.dbd-row-type {
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.dbd-row-field input,
.dbd-row-field textarea,
.dbd-row-field select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
    box-sizing: border-box;
    font-family: inherit;
}
.dbd-row-field textarea { resize: vertical; min-height: 80px; }
.dbd-row-modal-footer {
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #f9fafb;
}

.dbd-add-field {
    margin-top: 8px;
    background: transparent;
    border: 1px dashed #9ca3af;
    color: #4b5563;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.dbd-loading {
    padding: 20px;
    text-align: center;
    color: #6b7280;
}

.dbd-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 10px;
}

.dbd-hint {
    color: #6b7280;
    font-size: 12px;
    margin-top: 4px;
}
