/**
 * Tlog Editor Styles - Vanilla JavaScript Edition
 * Bootstrap 5 compatible
 * REDList branding (#be302a)
 */

/* Toolbar */
.tlog-editor-toolbar {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bs-light, #f8f9fa);
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    flex-wrap: wrap;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Transaction Metadata Card */
.tlog-editor-metadata {
    border-left: 4px solid #be302a;
}

.tlog-editor-metadata .form-label {
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.tlog-editor-metadata .fw-bold {
    color: var(--bs-body-color);
    font-size: 1.1rem;
}

/* Strings Container */
.tlog-editor-strings {
    padding-bottom: 1rem;
}

/* Individual String Card */
.tlog-editor-string {
    border: 1px solid var(--bs-border-color, #dee2e6);
    transition: all 0.2s ease;
}

.tlog-editor-string:hover {
    border-color: #be302a;
    box-shadow: 0 2px 8px rgba(190, 48, 42, 0.1);
}

.tlog-editor-string .card-header {
    background: var(--bs-light, #f8f9fa);
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    padding: 0.75rem 1rem;
    user-select: none;
}

.tlog-editor-string .card-header:hover {
    background: var(--bs-secondary-bg, #e9ecef);
}

.tlog-editor-string .card-body {
    padding: 1rem;
}

/* Badges */
.tlog-editor-string .badge.bg-primary {
    background-color: #be302a !important;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    padding: 0.35em 0.65em;
}

/* Field Table */
.tlog-editor-string table {
    margin-bottom: 0;
}

.tlog-editor-string table th {
    background: var(--bs-tertiary-bg, #f8f9fa);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--bs-secondary-color, #6c757d);
    border-bottom: 2px solid var(--bs-border-color, #dee2e6);
    position: sticky;
    top: 0;
    z-index: 10;
}

.tlog-editor-string table td {
    vertical-align: middle;
    padding: 0.5rem;
}

.tlog-editor-string table tbody tr:hover {
    background: var(--bs-secondary-bg, #e9ecef);
}

.tlog-editor-string table tbody tr.table-danger {
    background-color: rgba(220, 53, 69, 0.1) !important;
}

/* Field Input */
.tlog-editor-string input.form-control {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.tlog-editor-string input.form-control:focus {
    border-color: #be302a;
    box-shadow: 0 0 0 0.2rem rgba(190, 48, 42, 0.25);
}

.tlog-editor-string input.form-control.is-invalid {
    border-color: #dc3545;
}

.tlog-editor-string input.form-control.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Field Type Badge */
.badge.bg-info {
    background-color: #0dcaf0 !important;
    color: #000;
}

/* Success Button Override */
.btn-success {
    background-color: #be302a;
    border-color: #be302a;
}

.btn-success:hover {
    background-color: #9e2622;
    border-color: #9e2622;
}

.btn-success:focus {
    background-color: #9e2622;
    border-color: #9e2622;
    box-shadow: 0 0 0 0.2rem rgba(190, 48, 42, 0.5);
}

.btn-success:disabled {
    background-color: #6c757d;
    border-color: #6c757d;
    opacity: 0.65;
}

/* Button Overrides */
.tlog-editor-string .btn-outline-secondary:hover {
    background-color: var(--bs-secondary);
    border-color: var(--bs-secondary);
}

.tlog-editor-string .btn-outline-danger:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}

/* Validation Error Alert */
.alert-danger {
    border-left: 4px solid #dc3545;
}

/* Info Alert */
.alert-info {
    border-left: 4px solid #0dcaf0;
}

/* Unsaved Changes Badge */
.badge.bg-warning {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Modal Styling */
#tlogEditorModal .modal-content {
    border-radius: 0.5rem;
    overflow: hidden;
}

#tlogEditorModal .modal-body {
    padding: 0;
}

/* Scrollbar Styling for Modal Body */
#tlogEditorModal .modal-body::-webkit-scrollbar {
    width: 10px;
}

#tlogEditorModal .modal-body::-webkit-scrollbar-track {
    background: var(--bs-tertiary-bg, #f8f9fa);
}

#tlogEditorModal .modal-body::-webkit-scrollbar-thumb {
    background: #be302a;
    border-radius: 5px;
}

#tlogEditorModal .modal-body::-webkit-scrollbar-thumb:hover {
    background: #9e2622;
}

/* Table Responsive Wrapper */
.table-responsive {
    max-height: 400px;
    overflow-y: auto;
}

.table-responsive::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: var(--bs-tertiary-bg, #f8f9fa);
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #be302a;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #9e2622;
}

/* Loading Spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.2em;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .tlog-editor-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .tlog-editor-toolbar .ms-auto {
        margin-left: 0 !important;
        margin-top: 0.5rem;
        justify-content: space-between;
    }
    
    .tlog-editor-metadata .row {
        flex-direction: column;
    }
    
    .tlog-editor-metadata .col-md-3 {
        margin-bottom: 0.75rem;
    }
    
    /* Stack buttons on mobile */
    .tlog-editor-string .card-header > div:last-child {
        display: flex;
        gap: 0.25rem;
    }
    
    /* Make table scrollable horizontally on mobile */
    .table-responsive {
        max-height: none;
    }
}

/* Dark Mode Support */
[data-bs-theme="dark"] .tlog-editor-toolbar {
    background: #212529;
    border-bottom-color: #495057;
}

[data-bs-theme="dark"] .tlog-editor-string {
    border-color: #495057;
}

[data-bs-theme="dark"] .tlog-editor-string:hover {
    border-color: #be302a;
}

[data-bs-theme="dark"] .tlog-editor-string .card-header {
    background: #212529;
    border-bottom-color: #495057;
}

[data-bs-theme="dark"] .tlog-editor-string .card-header:hover {
    background: #2c3034;
}

[data-bs-theme="dark"] .tlog-editor-string table th {
    background: #2c3034;
}

[data-bs-theme="dark"] .tlog-editor-string table tbody tr:hover {
    background: #2c3034;
}

[data-bs-theme="dark"] .table-responsive::-webkit-scrollbar-track {
    background: #212529;
}

[data-bs-theme="dark"] #tlogEditorModal .modal-body::-webkit-scrollbar-track {
    background: #212529;
}

/* Print Styles */
@media print {
    #tlogEditorModal .modal-header,
    #tlogEditorModal .tlog-editor-toolbar {
        display: none;
    }
    
    .tlog-editor-string {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .tlog-editor-string .card-header button {
        display: none;
    }
}

/* Accessibility */
.tlog-editor-string .card-header:focus-visible {
    outline: 2px solid #be302a;
    outline-offset: 2px;
}

button:focus-visible {
    outline: 2px solid #be302a;
    outline-offset: 2px;
}

/* Animations */
.tlog-editor-string {
    animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Invalid Feedback */
.invalid-feedback {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Small Text */
.small, small {
    font-size: 0.875rem;
}

/* Toast Container */
#tlogEditorToastContainer {
    z-index: 9999;
}

/* Utility Classes */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Gap Utilities (if Bootstrap version doesn't have them) */
.gap-2 {
    gap: 0.5rem !important;
}

/* Flex Wrap */
.flex-wrap {
    flex-wrap: wrap !important;
}
/* Enhanced modal backdrop for nested modals */
.modal-backdrop.show:nth-of-type(2) {
    z-index: 1060;
}

.modal.show:nth-of-type(2) {
    z-index: 1070;
}