/* ============================================================================
   Impuesto Municipal - Estilos Nordy
   ============================================================================ */

/* CSS Variables - Branding Nordy */
:root {
    --bg: #ffffff;
    --card: #ffffff;
    --grid: #e5e7eb;
    --fg: #0b1f1e;
    --muted: #64748b;
    --primary: #003D31;       /* Calming green */
    --secondary: #75F8CB;     /* Energetic green */
    --accent: #89C3CB;        /* Introspective blue */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    color: var(--fg);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================================
   Layout
   ============================================================================ */

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--grid);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    height: 36px;
    width: auto;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.brand-tagline {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 400;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: 500;
    color: var(--fg);
    font-size: 0.875rem;
}

.user-email {
    font-size: 0.75rem;
    color: var(--muted);
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

/* ============================================================================
   Cards
   ============================================================================ */

.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    border: 1px solid var(--grid);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--grid);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--fg);
}

/* ============================================================================
   Forms
   ============================================================================ */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--fg);
}

.form-input,
.form-select {
    width: 100%;
    height: 48px;
    padding: 0 1rem;
    border: 1px solid var(--grid);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--fg);
    background: var(--bg);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 61, 49, 0.1);
}

.form-input.error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-input.has-selection {
    border-color: var(--primary);
    background: rgba(0, 61, 49, 0.02);
}

.form-select.error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Keyboard shortcut hints */
.shortcut-hint {
    font-size: 0.7rem;
    color: var(--muted);
    margin-left: 0.5rem;
    opacity: 0.7;
}

.form-input::placeholder {
    color: var(--muted);
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 48px;
    padding: 0 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #0c7c59 0%, #10b981 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(12, 124, 89, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--grid);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: var(--primary);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    width: 20px;
    height: 20px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* ============================================================================
   Table
   ============================================================================ */

.table-container {
    overflow-x: auto;
    margin-top: 1.5rem;
    border: 1px solid var(--grid);
    border-radius: var(--radius-md);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    text-align: left;
    padding: 1rem;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--grid);
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: rgba(0, 61, 49, 0.02);
}

.data-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.data-table tbody tr:nth-child(even):hover {
    background: rgba(0, 61, 49, 0.04);
}

.table-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--muted);
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: var(--primary);
    opacity: 0.3;
    display: block;
}

.empty-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 0.5rem;
}

.empty-text {
    font-size: 0.875rem;
    color: var(--muted);
    max-width: 400px;
    margin: 0 auto;
}

.table-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--grid);
    font-size: 0.875rem;
    color: var(--muted);
}

/* ============================================================================
   Login Page
   ============================================================================ */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e0f2fe 50%, #f0fdf4 100%);
}

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    height: 48px;
    margin-bottom: 1rem;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--muted);
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-form .btn-primary {
    width: 100%;
    margin-top: 0.5rem;
}

.login-error {
    background: #fef2f2;
    color: var(--error);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: none;
}

.login-error.show {
    display: block;
}

/* ============================================================================
   Loading & Alerts
   ============================================================================ */

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--muted);
    gap: 1rem;
}

.loading-text {
    text-align: center;
}

.loading-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--fg);
    margin-bottom: 0.25rem;
}

.loading-subtitle {
    font-size: 0.875rem;
    color: var(--muted);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 4px solid var(--grid);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn .spinner {
    width: 18px;
    height: 18px;
    border-width: 2px;
    margin: 0;
}

/* Skeleton Loading */
.skeleton-table {
    padding: 1rem;
}

.skeleton-header {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.skeleton-cell {
    height: 40px;
    background: linear-gradient(90deg, var(--grid) 0%, #f0f0f0 50%, var(--grid) 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-row {
    height: 48px;
    background: linear-gradient(90deg, #fafafa 0%, #f0f0f0 50%, #fafafa 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (max-width: 768px) {
    .header-content {
        padding: 1rem;
    }

    .main-content {
        padding: 1rem;
    }

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

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    .user-info {
        display: none;
    }

    .table-stats {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

/* ============================================================================
   Multi-select & Chips
   ============================================================================ */

.form-group-wide {
    grid-column: 1 / -1;
}

.form-group-wide .autocomplete-wrapper {
    width: 100%;
}

.form-group-wide .form-input {
    width: 100%;
    min-height: 52px;
    font-size: 1rem;
}

.multi-select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.multi-select-wrapper .autocomplete-wrapper {
    width: 100%;
}

.multi-select-wrapper .form-input {
    width: 100%;
}

.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 0;
}

.chips-container:empty {
    display: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: linear-gradient(135deg, rgba(0, 61, 49, 0.1) 0%, rgba(117, 248, 203, 0.2) 100%);
    border: 1px solid var(--primary);
    border-radius: 20px;
    font-size: 0.8125rem;
    color: var(--primary);
    font-weight: 500;
}

.chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    transition: all 0.2s ease;
}

.chip-remove:hover {
    background: var(--error);
    transform: scale(1.1);
}

/* ============================================================================
   Autocomplete
   ============================================================================ */

.autocomplete-wrapper {
    position: relative;
    flex: 1;
    width: 100%;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--grid);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-md);
    display: none;
}

.autocomplete-list.show {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--grid);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: rgba(0, 61, 49, 0.05);
}

.autocomplete-item.selected {
    background: rgba(0, 61, 49, 0.08);
    color: var(--primary);
    font-weight: 500;
}

.autocomplete-item.selected:hover {
    background: rgba(239, 68, 68, 0.1);
}

.check-icon {
    color: var(--success);
    font-weight: bold;
    margin-right: 4px;
}

.autocomplete-item mark {
    background: var(--secondary);
    color: var(--primary);
    padding: 0 2px;
    border-radius: 2px;
}

.autocomplete-empty {
    padding: 0.75rem 1rem;
    color: var(--muted);
    font-size: 0.875rem;
    text-align: center;
}

/* ============================================================================
   Date Input with Mask
   ============================================================================ */

.date-input-wrapper {
    position: relative;
}

.date-input-wrapper .form-input {
    font-family: 'Inter', monospace;
    letter-spacing: 0.5px;
}

/* ============================================================================
   Utilities
   ============================================================================ */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--muted);
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

/* ============================================================================
   Button Spinner (Small)
   ============================================================================ */

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.btn.loading .btn-text {
    opacity: 0.7;
}

.btn.loading .btn-icon {
    display: none;
}

.btn.loading .spinner-small {
    display: inline-block;
}

/* ============================================================================
   Empty State (Informative)
   ============================================================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    color: var(--muted);
    opacity: 0.5;
    margin-bottom: 1rem;
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 0.5rem;
}

.empty-state-text {
    font-size: 0.875rem;
    color: var(--muted);
}

.empty-state-text kbd {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    font-family: 'Inter', monospace;
    background: var(--grid);
    border: 1px solid #d1d5db;
    border-radius: 4px;
    box-shadow: 0 1px 0 #d1d5db;
}

/* ============================================================================
   Skeleton Loading (Improved)
   ============================================================================ */

.skeleton {
    background: linear-gradient(90deg, var(--grid) 0%, #f0f0f0 50%, var(--grid) 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-title {
    height: 24px;
    width: 150px;
}

.skeleton-text {
    height: 16px;
}

.skeleton-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--grid);
}

.skeleton-header-row {
    border-bottom: 2px solid var(--grid);
}

.skeleton-row .skeleton-cell {
    height: 32px;
    margin: 0;
}

/* ============================================================================
   Form Input Error State
   ============================================================================ */

.form-input.error,
.form-select.error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-input.error:focus,
.form-select.error:focus {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.form-error-message {
    font-size: 0.75rem;
    color: var(--error);
    margin-top: 0.25rem;
}

/* ============================================================================
   Pagination
   ============================================================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    border-top: 1px solid var(--grid);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--muted);
    min-width: 120px;
    text-align: center;
}

.btn-sm {
    height: 36px;
    padding: 0 1rem;
    font-size: 0.8125rem;
}

.btn-sm svg {
    width: 16px;
    height: 16px;
}

.page-size-select {
    height: 32px;
    padding: 0 0.75rem;
    border: 1px solid var(--grid);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--muted);
    background: var(--bg);
    cursor: pointer;
}

.page-size-select:focus {
    outline: none;
    border-color: var(--primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

