/* STYLE.CSS - FINAL VERSION v29 */
:root {
    --bg-body: hsl(222, 47%, 11%);
    --bg-surface: hsl(217, 33%, 17%);
    --bg-surface-glass: hsla(217, 33%, 17%, 0.98);
    --bg-readonly: hsla(222, 47%, 11%, 0.6);
    --bg-field-normal: hsla(0, 0%, 100%, 0.03);
    --bg-field-focus: hsla(263, 90%, 66%, 0.1);
    --primary: hsl(263, 90%, 66%);
    --primary-glow: hsla(263, 90%, 66%, 0.4);
    --status-read: transparent;
    --status-update: hsl(226, 71%, 40%);
    --status-insert: hsl(164, 86%, 20%);
    --status-delete: hsl(0, 70%, 35%);
    --text-delete: hsl(0, 94%, 82%);
    --info: hsl(188, 95%, 43%);
    --text-main: hsl(210, 40%, 98%);
    --text-secondary: hsl(215, 16%, 65%);
    --text-disabled: hsl(215, 16%, 47%);
    --border: hsla(215, 16%, 65%, 0.15);
    --border-focus: hsl(263, 90%, 66%);
    --shadow-lg: 0 10px 15px -3px hsla(0, 0%, 0%, 0.5);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    background-image: radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%), radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.1) 0px, transparent 50%);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: 13px;
}

app-root {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: var(--bg-surface-glass);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 50;
    flex-shrink: 0;
    height: 60px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(90deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.status-badge.active {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 15px;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-body);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid var(--border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(22px);
    background-color: hsl(0, 0%, 100%);
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
    position: relative;
}

.welcome-screen {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
}

.btn-large {
    font-size: 1.2rem;
    padding: 15px 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    box-shadow: 0 10px 25px rgba(124, 58, 237, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    color: white;
    border: none;
    cursor: pointer;
}

.btn-large:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(124, 58, 237, 0.5);
}

.btn-large:active {
    transform: translateY(0);
}

.main-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.content-area>* {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    min-height: 0;
}

grid-tropas,
grid-compras,
grid-productores,
grid-frigorificos,
grid-usuarios,
grid-vendedores,
grid-categorias {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
    flex: 1;
}

.grid-wrapper {
    background: var(--bg-surface);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    outline: none;
}

.grid-wrapper:focus {
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3);
}

.grid-toolbar {
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
}

.toolbar-btn {
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: hsl(0, 0%, 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.btn-add {
    background: linear-gradient(180deg, #065f46 0%, #064e3b 100%);
}

.btn-edit {
    background: linear-gradient(180deg, #1e40af 0%, #1e3a8a 100%);
}

.btn-del {
    background: linear-gradient(180deg, #991b1b 0%, #7f1d1d 100%);
}

.btn-save {
    background: linear-gradient(180deg, #064e3b 0%, #022c22 100%);
}

.btn-revert {
    background: linear-gradient(180deg, #c2410c 0%, #7c2d12 100%);
}

.btn-export {
    background: linear-gradient(180deg, #9ca3af 0%, #4b5563 100%);
}

.btn-ocr {
    background: linear-gradient(180deg, #7c3aed 0%, #5b21b6 100%);
}

.separator,
.separator-fixed {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 5px;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-secondary);
    width: 14px;
    height: 14px;
}

.search-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 6px 10px 6px 32px;
    border-radius: 20px;
    font-size: 0.85rem;
    outline: none;
    width: 220px;
}

.search-input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}

.table-scroll {
    flex: 1;
    overflow: auto;
    position: relative;
    outline: none;
    min-height: 0;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
    table-layout: fixed;
}

thead th {
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    padding: 10px 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

thead th:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: hsl(0, 0%, 100%);
}

.grid-wrapper table th:nth-child(1) {
    width: 60px;
}

.grid-wrapper table th:nth-child(2) {
    width: 80px;
}

.grid-wrapper table th:nth-child(3) {
    width: 110px;
}

.grid-wrapper table th:nth-child(4) {
    width: 80px;
}

.grid-wrapper table th:nth-child(5) {
    width: 100px;
}

.grid-wrapper table th:nth-child(6) {
    width: 150px;
}

.grid-wrapper table th:nth-child(7) {
    width: 80px;
}

.grid-wrapper table th:nth-child(8) {
    width: 90px;
}

.grid-wrapper table th:nth-child(9) {
    width: 80px;
}

.grid-wrapper table th:nth-child(10) {
    width: 90px;
}

.grid-wrapper table th:nth-child(11) {
    width: 80px;
}

.grid-wrapper table th:nth-child(12) {
    width: 70px;
}

.nested-table-container table th:nth-child(1) {
    width: 50px;
}

.nested-table-container table th:nth-child(2) {
    width: 80px;
}

.nested-table-container table th:nth-child(3) {
    width: 100px;
}

.nested-table-container table th:nth-child(4) {
    width: 90px;
}

.nested-table-container table th:nth-child(5) {
    width: 100px;
}

.nested-table-container table th:nth-child(6) {
    width: 90px;
}

.nested-table-container table th:nth-child(7) {
    width: 100px;
}

.nested-table-container table th:nth-child(8) {
    width: 70px;
}

tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    cursor: cell;
    user-select: none;
    white-space: nowrap;
    border-left: 4px solid transparent;
    overflow: hidden;
    text-overflow: ellipsis;
    /*height: 43px;*/
}

table.expand-to-parent {
    height: 100%;
}



tr.spacer-row {
    height: 100%;
    /* Sucks up all remaining height */
    background: transparent !important;
}

tr.spacer-row td {
    border: none !important;
    padding: 0 !important;
    height: auto !important;
}

tfoot td {
    padding: 8px 12px;
    color: var(--text-main);
    white-space: nowrap;
    position: sticky;
    bottom: 0;
    z-index: 10;
    background-color: var(--bg-surface);
    /* Opaque for scrolling */
    border-top: 2px solid var(--border);
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.3);
}

.unit-suffix {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-left: 3px;
    font-weight: normal;
}

tr.status-update>td:first-child {
    border-left-color: var(--status-update);
}

tr.status-insert>td:first-child {
    border-left-color: var(--status-insert);
}

tr.status-delete>td {
    color: var(--text-delete);
    text-decoration: line-through;
}

tr.status-delete>td:first-child {
    border-left-color: var(--status-delete);
    text-decoration: none;
}

tbody td.selected-cell {
    background-color: rgba(139, 92, 246, 0.25) !important;
    color: hsl(0, 0%, 100%);
}

tbody tr.active-row {
    background-color: rgba(139, 92, 246, 0.1);
}

/* ORGANIC INPUTS & SELECTS */
.inline-input,
.inline-select,
select,
.input-group input,
.input-group select {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    background-color: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: hsl(0, 0%, 100%);
    padding: 8px 10px;
    font-family: inherit;
    font-size: inherit;
    outline: none;
    display: block;
    transition: all 0.2s ease;
}

/* Specific overrides for grid cells to fit perfectly */
.inline-input,
.inline-select {
    padding: 0 8px;
    /* Tighter padding for grid */
    border-radius: 4px;
    background-color: var(--bg-surface);
    /* Slightly distinct from row */
}

/* Focus States */
.inline-input:focus,
.inline-select:focus,
select:focus,
.input-group input:focus,
.input-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.25);
    background-color: var(--bg-input-focus);
}

/* Organic Select Style with Visible Icon */
.inline-select,
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 30px !important;
    cursor: pointer;
}

.inline-select option,
select option {
    background-color: var(--bg-surface);
    color: var(--text-main);
    padding: 8px;
}

.input-right {
    text-align: right;
}

.action-cell {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    opacity: 0.6;
    padding: 2px;
}

.icon-btn:hover {
    opacity: 1;
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

.tag {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-block;
}

.tag-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.tag-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.code-badge {
    font-family: monospace;
    font-weight: 600;
    color: var(--info);
    padding: 1px 6px;
    font-size: 0.8rem;
}

.colored-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.colored-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 4px currentColor;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-card {
    background: #1e293b;
    width: 90%;
    max-width: 900px;
    height: 85vh;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    border-left: 6px solid transparent;
}

.modal-card.small {
    max-width: 450px;
    height: auto;
    max-height: 80vh;
}

.modal-card.status-update {
    border-left-color: var(--status-update);
}

.modal-card.status-insert {
    border-left-color: var(--status-insert);
}

.modal-card.status-delete {
    border-left-color: var(--status-delete);
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-body {
    padding: 20px 25px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* FIELD DISPLAY MODE (Read-only div) */
.field-read-mode {
    background: var(--bg-field-normal);
    border: 1px solid var(--border);
    color: hsl(0, 0%, 100%);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    min-height: 38px;
    display: flex;
    align-items: center;
    cursor: text;
    outline: none;
    transition: all 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.field-read-mode:focus {
    border-color: var(--border-focus);
    background-color: var(--bg-field-focus);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.field-read-mode.field-disabled {
    background-color: var(--bg-readonly);
    color: var(--text-disabled);
    cursor: default;
    border-color: transparent;
}

.field-read-mode.field-disabled:focus {
    box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
    outline: none;
}

.nested-table-container {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    flex: 1;
    overflow: hidden;
    /* Changed for scroll management */
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.nested-table-container:focus {
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3);
}

.close-btn {
    background: none;
    border: none;
    color: hsl(0, 0%, 100%);
    font-size: 1.5rem;
    cursor: pointer;
}

.btn {
    padding: 8px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary {
    background: var(--primary);
    color: hsl(0, 0%, 100%);
}

/* Validation Errors */
.input-group.has-error label {
    color: var(--danger);
}

.input-group.has-error .field-read-mode,
.input-group.has-error input,
.input-group.has-error .searchable-select-container .field-display {
    border-color: var(--danger);
}

.btn-cancel {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}




/* TOAST NOTIFICATION SYSTEM */
.toast-container-fixed {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-item {
    pointer-events: auto;
    width: 350px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: var(--text-main);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-item.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-item.toast-success {
    border-left-color: hsl(159, 84%, 39%);
}

.toast-item.toast-error {
    border-left-color: hsl(0, 84%, 60%);
}

.toast-item.toast-warning {
    border-left-color: hsl(38, 92%, 50%);
}

.toast-item.toast-info {
    border-left-color: hsl(217, 91%, 60%);
}

.toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-icon svg {
    width: 24px;
    height: 24px;
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast-info .toast-icon {
    color: #3b82f6;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 2px;
    font-size: 0.95rem;
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    opacity: 0.6;
}

.toast-close:hover {
    opacity: 1;
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toast-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: hsl(0, 0%, 100%);
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Toast Variants */
.toast-success {
    border-left-color: hsl(159, 84%, 39%);
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-error {
    border-left-color: hsl(0, 84%, 60%);
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-warning {
    border-left-color: hsl(38, 92%, 50%);
}

.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast-info {
    border-left-color: hsl(217, 91%, 60%);
}

.toast-info .toast-icon {
    color: #3b82f6;
}

/* Dynamic Badge Colors using CSS Variables */
.colored-badge-dynamic {
    --badge-color: #94a3b8;
    /* Default */
    background-color: color-mix(in srgb, var(--badge-color), transparent 80%);
    color: var(--badge-color);
    border: 1px solid color-mix(in srgb, var(--badge-color), transparent 60%);
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.colored-badge-dynamic .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
    background-color: var(--badge-color);
    box-shadow: 0 0 4px currentColor;
}

/* Modal Status Labels */
.modal-status-label {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.modal-status-label.status-insert {
    background-color: rgba(6, 95, 70, 0.4);
    color: #34d399;
}

.modal-status-label.status-update {
    background-color: rgba(30, 64, 175, 0.4);
    color: #60a5fa;
}

.modal-status-label.status-delete {
    background-color: rgba(153, 27, 27, 0.4);
    color: #f87171;
}

.nested-table-container .grid-toolbar {
    background: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid var(--border);
}

.badge-count {
    background: #475569;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.table-empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* SEARCHABLE SELECT */
.searchable-select-container {
    position: relative;
    width: 100%;
}

.searchable-select-container .dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    margin-top: 4px;
    padding: 0;
    list-style: none;
}

.searchable-select-container .dropdown-list li {
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-main);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.searchable-select-container .dropdown-list li:last-child {
    border-bottom: none;
}

.searchable-select-container .dropdown-list li:hover,
.searchable-select-container .dropdown-list li.selected {
    background-color: var(--primary);
    color: white;
}

.searchable-select-container .dropdown-list li.no-results {
    color: var(--text-secondary);
    cursor: default;
    font-style: italic;
    text-align: center;
}

/* Ensure inputs inside searchable select look correct */
.searchable-select-container .inline-input {
    width: 100%;
    box-sizing: border-box;
}

/* DROPDOWN GRID STYLES */
.searchable-select-container .dropdown-grid-container {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    /* Can be wider if needed */
    width: max-content;
    max-width: 500px;
    /* Cap width */
    max-height: 250px;
    overflow-y: auto;
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    margin-top: 4px;
}

.searchable-select-container .dropdown-grid {
    width: 100%;
    border-collapse: collapse;
}

.searchable-select-container .dropdown-grid th {
    background-color: var(--bg-input);
    color: var(--text-secondary);
    padding: 8px 12px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid var(--border);
}

.searchable-select-container .dropdown-grid td {
    padding: 8px 12px;
    color: var(--text-main);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    white-space: nowrap;
}

.searchable-select-container .dropdown-grid tr {
    cursor: pointer;
}

.searchable-select-container .dropdown-grid tr:hover,
.searchable-select-container .dropdown-grid tr.selected {
    background-color: var(--primary);
}

.searchable-select-container .dropdown-grid tr:hover td,
.searchable-select-container .dropdown-grid tr.selected td {
    color: white;
}

/* Global Progress Bar */
.global-progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 10000;
    pointer-events: none;
    overflow: hidden;
}

.global-progress-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--info));
    transform-origin: 0% 50%;
    transform: scaleX(0);
    transition: transform 0.2s ease-out;
}

.global-progress-bar.loading {
    animation: indeterminate 1.5s infinite linear;
    transform: scaleX(1);
    transform-origin: 0% 50%;
}

@keyframes indeterminate {
    0% {
        transform: translateX(-100%) scaleX(0.2);
    }

    50% {
        transform: translateX(0%) scaleX(0.5);
    }

    100% {
        transform: translateX(100%) scaleX(0.2);
    }
}

.expand-to-parent {
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    /* table-layout: auto (default) matches grid-tropas original behavior */
}

/* Grid Productores Column Overrides REMOVED to match dynamic behavior */

/* Grid Status Bar */
.grid-statusbar {
    padding: 8px 15px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

/* Inline Edit Inputs Redundant Block Removed */

/* GLASS CHIP STYLE (Defined by Agent) */
.glass-chip {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 4px 8px;
    color: #e2e8f0 !important;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.2;
}

.glass-chip .dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 8px;
    background-color: var(--badge-color);
    flex-shrink: 0;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
}

/* Nested Modal Stacking */
.modal-overlay.z-level-2 {
    z-index: 110 !important;
}

.modal-overlay.z-level-3 {
    z-index: 120 !important;
}


/* Nav Bar Component */
.main-nav {
    display: flex;
    gap: 5px;
    margin-left: 30px;
    flex: 1;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-btn:hover {
    color: hsl(0, 0%, 100%);
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
    color: hsl(0, 0%, 100%);
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Helper Classes to avoid inline styles */
.color-preview {
    width: 100%;
    height: 20px;
    border-radius: 4px;
}

.form-grid.single-col {
    grid-template-columns: 1fr !important;
}

.input-color-overlay {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    cursor: pointer;
}

/* DIALOG / MODAL CONFIRM */
.z-level-alert {
    z-index: 10000 !important;
}

.dialog-card {
    max-width: 400px;
    width: 90%;
    text-align: center;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dialog-icon-wrapper {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.dialog-icon-wrapper svg {
    width: 32px;
    height: 32px;
}

.dialog-icon-wrapper.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.dialog-title {
    font-size: 1.25rem;
    margin-bottom: 10px;
    color: white;
}

.dialog-message {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.dialog-actions {
    display: flex;
    gap: 15px;
    width: 100%;
    justify-content: center;
}

.btn-danger {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
}

.btn-danger:hover {
    background: #dc2626 !important;
}

/* --- ORGANIC LOGIN STYLES --- */

.login-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    overflow: hidden;
    background: #0f172a;
    z-index: 9999;
    /* Boost z-index */
}

/* ... (Blobs stay same) ... */

/* Enhanced Glass Card */
.login-card {
    /* ... */
    background: rgba(30, 41, 59, 0.85);
    /* Darker for better contrast */
    /* ... */
}

/* ... */

.login-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    color: hsl(0, 0%, 100%);
    /* Fallback */
    background: linear-gradient(to right, #ffffff, #cbd5e1);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

/* Background Blobs */
.organic-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 10s infinite ease-in-out;
    z-index: 0;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: linear-gradient(45deg, #8b5cf6, #ec4899);
    top: -50px;
    left: -50px;
    animation-delay: 0s;
}

.shape-2 {
    width: 350px;
    height: 350px;
    background: linear-gradient(45deg, #10b981, #3b82f6);
    bottom: -50px;
    right: -50px;
    animation-delay: 5s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(30px, -50px) rotate(10deg);
    }

    66% {
        transform: translate(-20px, 20px) rotate(-5deg);
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

/* Enhanced Glass Card */
.login-card {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: rgba(30, 41, 59, 0.6);
    /* Slightly more transparent */
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 30px;
    animation: fade-in-up 0.8s ease-out;
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 10px;
}

.login-logo {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    margin-bottom: 15px;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(to right, #fff, #cbd5e1);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 5px;
}

/* Floating Inputs */
.floating-input-group {
    position: relative;
    margin-bottom: 20px;
}

.floating-input-group input {
    width: 100%;
    padding: 18px 15px 6px 15px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    /* Slightly brighter border */
    border-radius: 12px;
    color: #ffffff;
    /* Pure white text */
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    height: 50px;
    z-index: 1;
    /* Input below label when label is "floating"? No, label is absolute */
}

.floating-input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
    background: rgba(15, 23, 42, 0.9);
    /* Darker on focus for contrast */
}

.floating-input-group label {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    color: #94a3b8;
    /* Explicit color hex */
    font-size: 1rem;
    transition: all 0.2s ease-out;
    pointer-events: none;
    z-index: 2;
    /* Ensure label is on top */
}

/* Float logic: focus or value present (Angular Class) */
.floating-input-group input:focus+label,
.floating-input-group input.ng-not-empty+label {
    top: 8px;
    /* Slightly lower than 0 to be inside input */
    transform: none;
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
}

/* Buttons */
.btn-block {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-lg {
    height: 50px;
    font-size: 1.1rem;
    border-radius: 12px;
    letter-spacing: 0.5px;
}

.btn-glow {
    position: relative;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border: none;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-glow:hover {
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.5);
    transform: translateY(-2px);
}

.btn-glow:active {
    transform: translateY(0);
}

/* Error Message */
.error-msg {
    color: #f87171;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 20px;
}

.shake {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

.login-footer {
    position: absolute;
    bottom: 20px;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.8rem;
    z-index: 10;
}