/* 
   PREMIUM TECHNICAL DESIGN SYSTEM 
   Architected for Antigravity - High Precision Cadastral UI
*/

:root {
    --tech-bg: #fafafa;
    --tech-card: #ffffff;
    --tech-border: #e4e4e7;
    --tech-accent: #18181b;
    --tech-accent-hover: #09090b;
    --tech-dark: #0f172a;
    --tech-label: #71717a;
    --tech-text: #27272a;
    --tech-input-bg: #ffffff;
    --tech-ring: rgba(24, 24, 27, 0.08);

    /* Professional Shadow System */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.04), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

body {
    background: #363C44 !important;
}

/* Base Container */
.premium-container {
    padding: 1rem;
    min-height: 100vh;
    background: #363C44;
    /* Matched to Topbar Background */
    font-family: 'Outfit', -apple-system, sans-serif;
}

/* Premium Card Architecture */
.premium-card {
    background: var(--tech-card);
    border-radius: 12px;
    border: 1px solid var(--tech-border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    margin-bottom: 1.25rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.premium-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--tech-border);
    background: linear-gradient(to right, var(--tech-card), var(--tech-bg));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.premium-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--tech-accent);
    margin: 0;
    letter-spacing: -0.01em;
}

/* Technical Form Elements */
.tech-section-header {
    background: #dde4eb;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-top: 1px solid var(--tech-border);
    border-bottom: 1px solid #cbd5e1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.tech-section-header:hover {
    background: #cbd5e1;
    color: #0f172a;
    padding-left: 1.1rem;
    /* Subtle movement hint */
}

.tech-section-header i:first-child {
    width: 20px;
    margin-right: 0.75rem;
    color: var(--tech-accent);
}

.tech-section-header .toggle-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.tech-section-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.tech-section-content {
    max-height: 2000px;
    /* Large value to allow expansion */
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0, 1, 0, 1);
}

.premium-panel-header {
    background: #e2e8f0;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 800;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--tech-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tech-section-content.collapsed {
    max-height: 0;
    transition: max-height 0.4s cubic-bezier(1, 0, 1, 0);
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border: none !important;
}

.tech-section-header.collapsed {
    border-bottom: none;
    border-radius: 0 0 6px 6px;
    /* Matches tech-data-block radius if it's the only child visible */
    transition-delay: 0.2s;
    /* Slight delay to match content collapse */
}

.premium-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1rem 1.25rem;
}

.tech-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: #f8fafc;
    /* Added for contrast contrast */
}

.tech-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--tech-label);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tech-input,
.tech-textarea {
    background: var(--tech-input-bg);
    border: 1.5px solid var(--tech-border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    color: var(--tech-text);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

/* Fix for Tech Input inside Input Groups */
.input-group .tech-input {
    flex: 1 1 auto;
    width: 1%;
    margin-bottom: 0;
}

.tech-input:focus,
.tech-textarea:focus {
    outline: none;
    border-color: var(--tech-accent);
    box-shadow: 0 0 0 4px var(--tech-ring);
    background: #ffffff;
}

/* Field Sizing Utilities */
.w-xs {
    max-width: 60px;
}

.w-sm {
    max-width: 100px;
}

.w-md {
    max-width: 200px;
}

.w-lg {
    max-width: 400px;
}

.w-full {
    width: 100%;
}

.f-grow {
    flex: 1 1 auto !important;
}

/* Modern Input Group Styling */
.input-group-modern {
    display: flex !important;
    align-items: stretch !important;
    width: 100% !important;
}

.input-group-modern .tech-input {
    border-radius: 0 8px 8px 0 !important;
    margin: 0 !important;
}

.input-group-modern .input-group-text {
    border-radius: 8px 0 0 8px !important;
    border-right: none !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.75rem;
}

.tech-textarea {
    min-height: 100px;
    resize: vertical;
}

/* --- ULTRA-TECHNICAL DATA SYSTEM --- */
.tech-data-block {
    background: #ffffff;
    border: 1px solid var(--tech-border);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}

/* --- NEW COMPACT NOMENCLATURA SYSTEM --- */
.nom-variant-box {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.nom-box-header {
    background: #e2e8f0;
    padding: 0.4rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 800;
    color: #475569;
    border-bottom: 1px solid #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: 'Outfit', sans-serif;
}

.nom-box-body {
    padding: 0.5rem;
}

.nom-grid-compact {
    width: 100%;
    border-collapse: separate;
    border-spacing: 4px;
}

.nom-grid-compact th {
    font-size: 0.65rem;
    color: #64748b;
    text-align: center;
    padding-bottom: 4px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.nom-grid-compact td {
    padding: 0;
}

.nom-field {
    width: 100%;
    height: 32px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    text-align: center;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-weight: 800;
    font-size: 0.9rem;
    color: #1e293b;
    background: #ffffff;
    transition: all 0.2s;
}

.nom-field:focus {
    outline: none;
    border-color: #18181b;
    box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.1);
    background: #ffffff;
}

.nom-grid-compact .is-uf th {
    color: #be123c;
}

.nom-grid-compact .is-uf .nom-field {
    border-color: #fecdd3;
    background: #fff1f2;
}

.nom-grid-compact .is-uf .nom-field:focus {
    border-color: #be123c;
    box-shadow: 0 0 0 3px rgba(190, 18, 60, 0.1);
}

.tech-data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Outfit', system-ui, sans-serif;
}

.tech-data-table th {
    background: #e2e8f0;
    color: #475569;
    font-size: 0.625rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--tech-border);
    border-right: 1px solid var(--tech-border);
    text-align: left;
}

.tech-data-table td {
    padding: 0.65rem 0.75rem;
    font-size: 0.9rem;
    color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
    border-right: 1px solid #f1f5f9;
}

.tech-data-table tr:last-child td {
    border-bottom: none;
}

.tech-data-table th:last-child,
.tech-data-table td:last-child {
    border-right: none;
}

.nom-grid-table .is-uf th {
    background: #be123c !important;
    /* Distinct dark red for UF header */
    color: #ffffff !important;
}

/* Field Display within Tables */
.tech-val {
    font-weight: 600;
    color: var(--tech-accent);
}

.tech-unit {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-left: 0.25rem;
}

/* Fix for Side-by-Side Overlap */
.view-main-card {
    position: relative;
    z-index: 1;
}

.view-side-card {
    position: sticky;
    top: 20px;
}

/* Technical Inputs for Tables */
.tech-input-compact {
    width: 100%;
    border: none;
    background: transparent;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--tech-accent);
    outline: none;
    transition: background 0.2s;
}

.tech-input-compact:focus {
    background: #f8fafc;
    box-shadow: inset 0 0 0 1px var(--tech-border);
}

.tech-section-content {
    overflow-x: auto;
    /* Prevent layout breaking on small width */
}

.nom-table .nom-input:focus {
    background: #fdf2f8;
}

/* Premium Action Buttons */
.premium-actions {
    padding: 1rem 1.25rem;
    background: #f8fafc;
    border-top: 1px solid var(--tech-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.btn-premium {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none !important;
}

.btn-premium-primary {
    background: var(--tech-accent);
    color: #ffffff !important;
    border-color: var(--tech-accent);
}

.btn-premium-primary:hover {
    background: var(--tech-accent-hover);
    border-color: var(--tech-accent-hover);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-premium-secondary {
    background: #ffffff;
    color: var(--tech-text) !important;
    border-color: var(--tech-border);
}

.btn-premium-secondary:hover {
    background: #fafafa;
    border-color: #d4d4d8;
    color: #000000 !important;
}

/* Premium Table Experience */
.premium-table-container {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--tech-border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-family: 'Outfit', sans-serif;
}

/* Docking logic for toolbar */
.table-toolbar+.premium-table-container {
    border-top: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: 0 !important;
}

.premium-table {
    width: 100%;
    min-width: max-content;
    border-collapse: separate;
    border-spacing: 0;
}

/* Enhanced Table Typography and Spacing */
.premium-table th {
    background: #1e293b;
    padding: 0.8rem 1rem;
    font-size: 0.7rem;
    font-weight: 800;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 2px solid #3b82f6;
    white-space: nowrap;
}

.premium-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1.5px solid #e2e8f0;
    /* Removed border-right */
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.premium-table th:last-child,
.premium-table td:last-child {
    border-right: none;
}

.premium-table tr:hover td {
    background: #f8fafc;
}

/* Property Differentiation (Pronounced Ledger Style) */
.row-tierra td:first-child {
    border-left: 4px solid #94a3b8 !important;
}

.row-ph td:first-child {
    border-left: 4px solid #d97706 !important;
}

.row-debt td:first-child {
    border-left: 4px solid #ef4444 !important;
}

.row-tierra td,
.row-ph td,
.row-debt td {
    background-color: #f8fafc !important;
}

.premium-table tr.row-tierra:hover td {
    background-color: #f1f5f9 !important;
}

.premium-table tr.row-ph:hover td {
    background-color: rgba(217, 119, 6, 0.08) !important;
}

.premium-table tr.row-debt:hover td {
    background-color: rgba(239, 68, 68, 0.08) !important;
}

.premium-table tr.row-project td {
    background-color: #e2e8f0 !important;
    /* Gris 2 tonos más oscuro */
}

.premium-table tr.row-project:hover td {
    background-color: #cbd5e1 !important;
}

.premium-table tr.row-inquiry td {
    background-color: #f8fafc !important;
    /* Gris Suave */
}

.premium-table tr.row-inquiry:hover td {
    background-color: #f1f5f9 !important;
}

/* Vertical Status Label */
.status-vertical-label {
    writing-mode: vertical-lr;
    transform: rotate(180deg);
    font-size: 0.6rem;
    font-weight: 800;
    padding: 6px 2px;
    border-radius: 6px;
    letter-spacing: 0.05em;
    color: white;
    text-align: center;
    line-height: 1;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
    text-transform: uppercase;
}

.table-toolbar {
    padding: 1rem 1.75rem;
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    /* Medium Slate Gray */
    border-radius: 16px 16px 0 0;
    border: 1px solid #475569;
    border-bottom: 3px solid var(--tech-accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 8px 20px -5px rgba(0, 0, 0, 0.25);
    position: relative;
    z-index: 10;
    margin-top: 1rem;
    color: #f1f5f9;
}

.table-toolbar .input-group-sm {
    background: #ffffff;
    /* White background */
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 4px 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 450px;
    box-shadow: var(--shadow-sm);
}

.table-toolbar .input-group-sm:focus-within {
    background: #ffffff;
    border-color: var(--tech-accent);
    box-shadow: 0 0 0 4px var(--tech-ring);
}

.table-toolbar .input-group-text {
    background: transparent !important;
    border: none !important;
    color: #64748b !important;
    /* Darker icon color */
}

.table-toolbar .form-control {
    background: transparent !important;
    border: none !important;
    font-size: 0.95rem;
    font-weight: 500;
    color: #1e293b !important;
    /* Dark text color */
}

.table-toolbar .form-control::placeholder {
    color: #94a3b8 !important;
}

.table-toolbar .form-control:focus {
    box-shadow: none !important;
}

/* Dropdown Visibility Fix for Dark Technical Ribbons */
.table-toolbar select.text-white option {
    background-color: #1e293b !important;
    color: #f8fafc !important;
}

.table-toolbar select.form-select.text-white {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e") !important;
}

/* Ensure consistency in mobile/native views */
@media (prefers-color-scheme: light) {
    select.text-white option {
        background-color: #1e293b;
        color: white;
    }
}

/* Badge Styling */
/* Monochromatic Badges */
.premium-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid transparent;
}

.badge-info {
    background: #f4f4f5;
    color: #3f3f46;
    border-color: #e4e4e7;
}

.badge-success {
    background: #27272a;
    color: #ffffff;
}

.badge-warning {
    background: #ffffff;
    color: #27272a;
    border-color: #27272a;
}

/* Stats Card Styling */
.stats-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--tech-border);
    transition: transform 0.2s ease;
}

.stats-card:hover {
    transform: translateY(-2px);
}

.stats-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.stats-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: #64748b;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stats-value {
    font-size: 1.15rem;
    font-weight: 750;
    line-height: 1;
}

/* Background Soft Utilities */
.bg-soft-primary {
    background: #e0f2fe;
    color: #0369a1;
}

.bg-soft-info {
    background: #e0faff;
    color: #0891b2;
}

.bg-soft-success {
    background: #f0fdf4;
    color: #15803d;
}

.bg-soft-danger {
    background: #fef2f2;
    color: #b91c1c;
}

.bg-soft-warning {
    background: #fffbeb;
    color: #b45309;
}

/* Display Box for View Mode */
.tech-display-box {
    background: #f8fafc;
    border: 1px solid var(--tech-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    color: var(--tech-text);
    min-height: 48px;
    display: flex;
    align-items: center;
}

/* Technical Monospace Ledger Utility */
.tech-mono {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-weight: 650;
    letter-spacing: -0.02em;
    color: var(--tech-accent);
}

.tech-num {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-weight: 700;
    text-align: right;
}

.premium-table .text-tech {
    color: var(--tech-accent);
    font-weight: 700;
}

.last-mb-0:last-child {
    margin-bottom: 0 !important;
}

/* --- Sidebar Pastel Groups --- */
.nav-links li.sidebar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px;
    margin: 8px 10px;
    border-radius: 14px;
    transition: all 0.3s ease;
}

.sidebar-group a {
    margin: 0 !important;
    width: 40px;
    height: 40px;
}

@media screen and (max-width: 768px) {
    .sidebar-group a {
        width: 100% !important;
        height: 44px;
        padding: 0 1rem;
    }

    .nav-links li.sidebar-group {
        border-radius: 8px;
        margin: 6px 12px;
    }
}

/* Group 1: Pastel Blue */
.sidebar-group.pastel-group-1 {
    background: rgba(125, 211, 252, 0.18);
    border: 1px solid rgba(125, 211, 252, 0.25);
    box-shadow: inset 0 0 10px rgba(125, 211, 252, 0.05);
}

.sidebar-group.pastel-group-1 a:hover i,
.sidebar-group.pastel-group-1 a.active i {
    color: #7dd3fc !important;
}

.sidebar-group.pastel-group-1 a.active {
    background: rgba(125, 211, 252, 0.2) !important;
    border-color: rgba(125, 211, 252, 0.3) !important;
}

/* Group 2: Pastel Green */
.sidebar-group.pastel-group-2 {
    background: rgba(134, 239, 172, 0.1);
    border: 1px solid rgba(134, 239, 172, 0.15);
}

.sidebar-group.pastel-group-2 a:hover i,
.sidebar-group.pastel-group-2 a.active i {
    color: #86efac !important;
}

.sidebar-group.pastel-group-2 a.active {
    background: rgba(134, 239, 172, 0.2) !important;
    border-color: rgba(134, 239, 172, 0.3) !important;
}

/* Group 3: Pastel Amber (Orange/Yellow) */
.sidebar-group.pastel-group-3 {
    background: rgba(253, 186, 116, 0.1);
    border: 1px solid rgba(253, 186, 116, 0.15);
}

.sidebar-group.pastel-group-3 a:hover i,
.sidebar-group.pastel-group-3 a.active i {
    color: #fdba74 !important;
}

.sidebar-group.pastel-group-3 a.active {
    background: rgba(253, 186, 116, 0.2) !important;
    border-color: rgba(253, 186, 116, 0.3) !important;
}

/* Group 4: Pastel Purple */
.sidebar-group.pastel-group-4 {
    background: rgba(196, 181, 253, 0.1);
    border: 1px solid rgba(196, 181, 253, 0.15);
}

.sidebar-group.pastel-group-4 a:hover i,
.sidebar-group.pastel-group-4 a.active i {
    color: #c4b5fd !important;
}

.sidebar-group.pastel-group-4 a.active {
    background: rgba(196, 181, 253, 0.2) !important;
    border-color: rgba(196, 181, 253, 0.3) !important;
}