/**
 * DataSpur V2 - Hierarchy Management Styles
 * Extends main styles.css with hierarchy-specific components
 */

/* Page Layout */
.page-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    margin-top: -8px;
    margin-bottom: 24px;
}

.hierarchy-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Hierarchy Card */
.hierarchy-card {
    padding: 24px;
}

.hierarchy-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.hierarchy-card .card-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hierarchy-card .card-header-left h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 500;
}

.hierarchy-card .card-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Badge */
.badge {
    background: rgba(var(--rgb-sunflower-gold), 0.2);
    color: rgba(var(--rgb-sunflower-gold), 1);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Table Styles */
.hierarchy-table {
    width: 100%;
    border-collapse: collapse;
}

.hierarchy-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 500;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.hierarchy-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.hierarchy-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.hierarchy-table .loading-cell {
    text-align: center;
    padding: 40px;
    color: rgba(255, 255, 255, 0.5);
}

.hierarchy-table .loading-cell .material-symbols-outlined {
    margin-right: 8px;
    vertical-align: middle;
}

.hierarchy-table .empty-cell {
    text-align: center;
    padding: 40px;
    color: rgba(255, 255, 255, 0.5);
}

/* Icon in table */
.table-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
}

.table-icon .material-symbols-outlined {
    font-size: 20px;
}

/* Color swatch */
.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-action {
    background: transparent;
    border: none;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.btn-action.edit:hover {
    color: rgba(var(--rgb-sunflower-gold), 1);
}

.btn-action.delete:hover {
    color: #ef5350;
}

/* Select Input */
.select-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    min-width: 150px;
}

.select-input:focus {
    outline: none;
    border-color: rgba(var(--rgb-sunflower-gold), 0.5);
}

.select-input option {
    background: #2a2a2a;
    color: white;
}

/* Button Small */
.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-sm .material-symbols-outlined {
    font-size: 18px;
}

/* Spinning animation */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spinning {
    animation: spin 1s linear infinite;
}

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

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}

.modal.modal-sm {
    max-width: 400px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 500;
}

.modal-body {
    margin-bottom: 24px;
}

.modal-body p {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Form Styles */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 12px 14px;
    color: white;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: rgba(var(--rgb-sunflower-gold), 0.5);
    background: rgba(255, 255, 255, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.form-group select option {
    background: #2a2a2a;
    color: white;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
}

/* Icon Picker */
.icon-picker-wrapper {
    position: relative;
}

.icon-picker-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 10px 14px;
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-picker-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
}

.icon-picker-btn .material-symbols-outlined:first-child {
    font-size: 20px;
}

.icon-picker-btn .material-symbols-outlined:last-child {
    margin-left: auto;
    font-size: 18px;
    opacity: 0.6;
}

.icon-picker-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: rgba(30, 30, 40, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 12px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.icon-picker-dropdown.active {
    display: block;
}

.icon-picker-category {
    margin-bottom: 12px;
}

.icon-picker-category:last-child {
    margin-bottom: 0;
}

.icon-picker-category-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
    padding-left: 4px;
}

.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 4px;
}

.icon-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.7);
}

.icon-option:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.icon-option.selected {
    background: rgba(var(--rgb-sunflower-gold), 0.2);
    color: rgba(var(--rgb-sunflower-gold), 1);
}

.icon-option .material-symbols-outlined {
    font-size: 22px;
}

/* Color Picker */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-picker-wrapper input[type="color"] {
    width: 50px;
    height: 42px;
    padding: 2px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.color-preview {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

/* Button Danger */
.btn-danger {
    background: rgba(239, 83, 80, 0.2);
    border: 1px solid rgba(239, 83, 80, 0.4);
    color: #ef5350;
}

.btn-danger:hover {
    background: rgba(239, 83, 80, 0.3);
    border-color: rgba(239, 83, 80, 0.6);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    border-radius: 10px;
    color: white;
    font-weight: 500;
    display: none;
    align-items: center;
    gap: 10px;
    z-index: 1100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.3s ease;
}

.toast.active {
    display: flex;
}

.toast.success {
    background: rgba(76, 175, 80, 0.95);
}

.toast.error {
    background: rgba(239, 83, 80, 0.95);
}

.toast.info {
    background: rgba(var(--rgb-sunflower-gold), 0.95);
    color: #1a1a1a;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Source name in sections table */
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .hierarchy-card {
        padding: 16px;
    }

    .hierarchy-card .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .hierarchy-card .card-header-right {
        width: 100%;
        flex-wrap: wrap;
    }

    .select-input {
        flex: 1;
        min-width: 120px;
    }

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

    .modal {
        max-width: 100%;
        margin: 10px;
    }

    .table-wrapper {
        overflow-x: auto;
    }

    .hierarchy-table {
        min-width: 600px;
    }
}
