/* =============================================================
   ULTRA COMPACT DASHBOARD - Everything fits in viewport
   ============================================================= */

/* FORMS - COMPACT GRID LAYOUT */
/* FORMS - COMPACT GRID LAYOUT - STRONG OVERRIDE */
.form-row,
.form-row[style] {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    gap: 1rem !important;
    margin-bottom: 0.5rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Force removal of old flex styles if present via style attribute */
.form-row>* {
    max-width: none !important;
    width: 100% !important;
    flex: none !important;
}

.form-group {
    margin-bottom: 0.5rem !important;
    min-width: 0 !important;
    /* Fix grid overflow */
}

.form-group label {
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    color: #4B5563 !important;
    margin-bottom: 0.25rem !important;
    display: block !important;
    text-transform: uppercase !important;
    letter-spacing: 0.02em !important;
}

/* CRITICAL FIX: Neutralize Inline Padding in Cards */
.card>div[style*="padding"],
.card>div[style*="Padding"],
.card>div[style*="PADDING"] {
    padding: 0 !important;
    margin: 0 !important;
}

/* Standardize Card-Header Structure */
.card-header {
    background: transparent !important;
    border-bottom: 1px solid #F3F4F6 !important;
    padding: 0 0 0.5rem 0 !important;
    margin: 0 0 0.75rem 0 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.card-header h3 {
    margin: 0 !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    color: #111827 !important;
}

.card-header p {
    margin: 0 !important;
    font-size: 0.8rem !important;
    color: #6B7280 !important;
}

/* Remove Extra Spacing from Wrapper Divs */
.search-form,
.card>div:not(.card-header):not(.table-container):not([id]) {
    margin: 0 !important;
}

/* Ensure Direct Card Content has Proper Spacing */
.card>h3:first-child {
    margin-top: 0 !important;
    margin-bottom: 0.75rem !important;
}

.card>p:not([style*="padding"]) {
    margin-bottom: 0.75rem !important;
}


/* INPUTS & SELECTS - COMPACT (Applied Globally) */
.input,
select,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="file"],
textarea {
    font-size: 0.85rem !important;
    padding: 0.4rem 0.75rem !important;
    border-radius: 8px !important;
    border: 1px solid #E5E7EB !important;
    height: auto !important;
    width: 100% !important;
    box-shadow: none !important;
    background-color: white !important;
    transition: all 0.2s ease !important;
}

/* DATE INPUTS - Better formatting */
input[type="date"] {
    color: #374151 !important;
    font-family: inherit !important;
    position: relative !important;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer !important;
    opacity: 0.6 !important;
    filter: invert(0.5) !important;
}

input[type="date"]:hover::-webkit-calendar-picker-indicator {
    opacity: 1 !important;
}

/* Focus states */
.input:focus,
select:focus,
input[type="date"]:focus {
    border-color: #6C5DD3 !important;
    box-shadow: 0 0 0 3px rgba(108, 93, 211, 0.1) !important;
    outline: none !important;
}

/* SELECT/DROPDOWN - Enhanced styling */
select,
select.input {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23374151' d='M6 9L1 4h10z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 12px !important;
    padding-right: 2.5rem !important;
    cursor: pointer !important;
    font-weight: 500 !important;
}

select:hover {
    border-color: #9CA3AF !important;
}

/* Enhanced select option styling */
select option {
    padding: 0.75rem !important;
    font-weight: 500 !important;
    font-size: 0.9rem !important;
    color: #374151 !important;
    background: white !important;
    line-height: 1.5 !important;
}

/* Disabled options */
select option:disabled {
    color: #9CA3AF !important;
    font-style: italic !important;
}

/* Selected option in dropdown */
select option:checked {
    background: #E0E7FF !important;
    color: #4338CA !important;
    font-weight: 600 !important;
}

/* Hover effect for options (works in some browsers) */
select option:hover {
    background: #F3F4F6 !important;
}

/* CARDS - Standardize Padding */
.card {
    padding: 0.75rem !important;
    /* Reduced for tighter compact layout */
}

/* SECTION TITLES - Consistent Size */
.section-title {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    color: #111827 !important;
    margin-bottom: 1rem !important;
}

/* GLOBAL CONTAINER - NEUTRALIZE */
.container {
    max-width: none !important;
    width: auto !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* SECTIONS - FORCE FULL WIDTH IN FLEX CONTAINER */
.content-area>.section {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
}

/* REMOVE ALL INLINE COLORS */
.stat-card [style*="color"] {
    color: inherit !important;
}

/* STAT CARDS - ULTRA COMPACT */
.stat-card {
    background: white !important;
    border: none !important;
    border-radius: 16px !important;
    padding: 0.75rem !important;
    /* Very small padding */
    gap: 0.5rem !important;
}

.stat-card .card-icon {
    background: #F3F4F6 !important;
    color: #1C1C24 !important;
    font-size: 1.5rem !important;
    /* Much smaller icon */
    font-weight: 700 !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 10px !important;
}

.stat-card.card-primary-soft {
    background: #E8E7FF !important;
}

.stat-card.card-primary-soft .card-icon,
.stat-card .card-icon.blue {
    background: white !important;
    color: #6C5DD3 !important;
}

.stat-card .card-content h3 {
    font-size: 0.7rem !important;
    margin: 0 0 0.2rem 0 !important;
    color: #6B7280 !important;
    text-transform: uppercase;
}

.stat-card .stat-number {
    font-size: 1.25rem !important;
    /* Smaller numbers */
    color: #1F2937 !important;
    margin: 0 !important;
    line-height: 1;
}

.stat-card .text-sm,
.stat-card .text-gray,
.stat-card p {
    font-size: 0.7rem !important;
    margin: 0.2rem 0 0 0 !important;
    color: #6B7280 !important;
}

/* BUTTONS */
.btn-primary,
button.btn-primary {
    background: #6C5DD3 !important;
    color: white !important;
    border: none !important;
    padding: 0.5rem 1rem !important;
    /* Smaller buttons */
    font-size: 0.85rem !important;
}

.btn-secondary,
.btn-info {
    padding: 0.5rem 1rem !important;
    font-size: 0.85rem !important;
}

/* SIDEBAR */
.sidebar {
    background: #1C1C24 !important;
}

/* BODY */
body {
    background: #F3F4F6 !important;
}

/* CARDS */
.card {
    background: white !important;
    border: 1px solid #E5E7EB !important;
    border-radius: 12px !important;
}

.card h3 {
    font-size: 0.9rem !important;
    margin: 0 0 0.75rem 0 !important;
    font-weight: 600;
}

/* TABLES */
table thead {
    background: #FAFAFB !important;
    color: #6B7280 !important;
}

table thead th {
    color: #6B7280 !important;
    font-size: 0.75rem !important;
    padding: 0.5rem 0.75rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
}

table tbody td {
    font-size: 0.8rem !important;
    padding: 0.5rem 0.75rem !important;
    color: #374151 !important;
}

/* TABLES - FULL WIDTH EXPANSION */
.table-container {
    width: 100% !important;
    overflow-x: auto !important;
    margin: 0 !important;
}

.table,
table {
    width: 100% !important;
    table-layout: auto !important;
    /* Allow columns to size based on content */
    border-collapse: collapse !important;
}

/* Specific sections that should have expanded tables */
#dashboard table,
#buscar table,
#analisis table,
#archivador table {
    width: 100% !important;
    min-width: 100% !important;
}

/* Ensure table cells distribute space efficiently */
.table th,
.table td {
    white-space: nowrap !important;
    /* Prevent text wrapping for compact look */
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Allow certain columns to wrap if needed (descriptions, etc) */
.table td[style*="white-space: normal"],
.table td.description,
.table td:nth-child(3) {
    /* Usually description is 3rd column */
    white-space: normal !important;
    word-wrap: break-word !important;
    min-width: 200px !important;
    max-width: 400px !important;
}

/* RESPONSIVE OPTIMIZATION (Mobile/Tablet) */
@media (max-width: 768px) {

    /* Reduce padding on mobile */
    #dashboard .container,
    .container {
        padding: 0 0.5rem !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Stack grid elements */
    .form-row {
        grid-template-columns: 1fr !important;
    }

    /* Adjust Card padding for mobile */
    .card {
        padding: 0.75rem !important;
    }

    /* Ensure tables can still scroll */
    .table-container {
        border-right: 1px solid #eee;
    }
}