/* Custom Admin Styles */

/* Variables */
:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --border-radius: 0.5rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --box-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Welcome Card */
.welcome-card {
    background: linear-gradient(135deg, var(--primary-color), #4a90e2);
    color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
}

.welcome-card h1,
.welcome-card h2,
.welcome-card h3,
.welcome-card p {
    color: white !important;
}

.welcome-card .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
}

.welcome-icon {
    font-size: 3rem;
    opacity: 0.8;
}

/* Stats Cards */
.stats-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--box-shadow-lg);
}

.stats-card-body {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stats-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.stats-icon.primary { background: var(--primary-color); }
.stats-icon.success { background: var(--success-color); }
.stats-icon.warning { background: var(--warning-color); }
.stats-icon.danger { background: var(--danger-color); }

.stats-content {
    flex: 1;
}

.stats-number {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    color: var(--dark-color);
}

.stats-label {
    color: #6c757d;
    margin: 0;
    font-size: 0.875rem;
}

.stats-trend {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.trend-icon.up { color: var(--success-color); }
.trend-icon.down { color: var(--danger-color); }
.trend-text { color: #6c757d; }

/* Chart Cards */
.chart-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.chart-card-header {
    padding: 1.25rem 1.5rem 0;
    border-bottom: none;
    display: flex;
    justify-content: between;
    align-items: center;
}

.chart-card-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-color);
}

.chart-card-actions {
    margin-left: auto;
}

.chart-card-body {
    padding: 1.5rem;
}

/* Activity Card */
.activity-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
    height: 100%;
}

.activity-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.activity-card-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-color);
}

.activity-card-body {
    padding: 0;
}

.activity-list {
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

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

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    color: white;
}

.activity-icon.primary { background: var(--primary-color); }
.activity-icon.success { background: var(--success-color); }
.activity-icon.warning { background: var(--warning-color); }

.activity-content {
    flex: 1;
}

.activity-text {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
}

.activity-time {
    color: #6c757d;
    font-size: 0.75rem;
}

/* Table Card */
.table-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.table-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.table-card-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-color);
}

.table-card-body {
    padding: 0;
}

/* Page Header */
.page-header {
    background: white;
    padding: 1.5rem 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.page-actions {
    display: flex;
    gap: 0.5rem;
}

/* Filters Card */
.filters-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.filters-card-body {
    padding: 1.5rem;
}

/* Subsidies Table */
.subsidies-table-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.subsidies-table-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: between;
    align-items: center;
}

.subsidies-table-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-color);
}

.subsidies-table-body {
    padding: 0;
}

.subsidies-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--dark-color);
    border-bottom: 2px solid #dee2e6;
}

/* Bulk Actions */
.bulk-actions {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-top: 3px solid var(--primary-color);
}

/* Button Group Improvements */
.btn-group .btn {
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-top-left-radius: 0.25rem;
    border-bottom-left-radius: 0.25rem;
}

.btn-group .btn:last-child {
    border-top-right-radius: 0.25rem;
    border-bottom-right-radius: 0.25rem;
}

.btn-group .btn + .btn {
    margin-left: -1px;
}

/* Table Improvements */
.subsidies-table {
    width: 100% !important;
    table-layout: auto;
}

.subsidies-table .btn-group {
    display: flex;
    justify-content: center;
    gap: 2px;
}

.subsidies-table td {
    vertical-align: middle;
    padding: 0.75rem 0.5rem;
}

.subsidies-table th {
    padding: 0.75rem 0.5rem;
    white-space: nowrap;
}

.subsidies-table .form-check-input {
    margin: 0;
}

/* Column widths for better distribution */
.subsidies-table th:nth-child(1),
.subsidies-table td:nth-child(1) {
    width: 40px;
    text-align: center;
}

.subsidies-table th:nth-child(2),
.subsidies-table td:nth-child(2) {
    width: 60px;
    text-align: center;
}

.subsidies-table th:nth-child(3),
.subsidies-table td:nth-child(3) {
    width: 200px;
    min-width: 180px;
}

.subsidies-table th:nth-child(4),
.subsidies-table td:nth-child(4) {
    width: 120px;
    text-align: center;
}

.subsidies-table th:nth-child(5),
.subsidies-table td:nth-child(5) {
    width: 100px;
    text-align: center;
}

.subsidies-table th:nth-child(6),
.subsidies-table td:nth-child(6) {
    width: 100px;
    text-align: center;
}

.subsidies-table th:nth-child(7),
.subsidies-table td:nth-child(7) {
    width: 100px;
    text-align: right;
}

.subsidies-table th:nth-child(8),
.subsidies-table td:nth-child(8) {
    width: 150px;
    text-align: center;
}

/* Responsive table improvements */
.table-responsive {
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.subsidies-table-body .table-responsive {
    max-height: 70vh;
    overflow-y: auto;
}

/* Better button group spacing */
.subsidies-table .btn-group .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.subsidies-table .btn-group .btn:not(:last-child) {
    margin-right: 1px;
}

/* Text overflow handling */
.subsidies-table td {
    overflow: hidden;
    text-overflow: ellipsis;
}

.subsidies-table td:nth-child(3) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Loading States */
.btn-loading {
    position: relative;
}

.btn-loading .fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Status Badges Improvements */
.badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    font-weight: 500;
}

/* Table Info Badge */
.table-info .badge {
    font-size: 0.8rem;
    font-weight: 600;
}

/* Checkbox Improvements */
.form-check-input:checked[type=checkbox] {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-check-input:indeterminate {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Hover Effects for Table Rows */
.subsidies-table tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
    transform: none;
    transition: background-color 0.2s ease;
}

/* Filter Improvements */
.filters-card .form-label.small {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

/* Page Actions */
.page-actions .btn {
    box-shadow: var(--box-shadow);
    border: none;
}

.page-actions .btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--box-shadow-lg);
}

/* Page Actions in welcome card */
.welcome-card .page-actions .btn {
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.welcome-card .page-actions .btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: white;
}

/* Modal Improvements */
.modal-lg .modal-content {
    box-shadow: var(--box-shadow-lg);
    border: none;
    border-radius: var(--border-radius);
}

.modal-header {
    background: var(--light-color);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
}

.modal-title {
    color: var(--dark-color);
    font-weight: 600;
}

.modal-body .card {
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: none;
}

.modal-body .card-header {
    background: rgba(13, 110, 253, 0.1);
    border-bottom: 1px solid rgba(13, 110, 253, 0.2);
}

.modal-body .card-title {
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
}

.modal-body .form-label.small {
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

.modal-body .fw-bold {
    color: var(--dark-color);
}

.modal-body .font-monospace {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.85rem;
}

.modal-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background: var(--light-color);
    border-bottom-left-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
}

/* Detail Modal Specific */
#detalleSubsidioModal .modal-body {
    padding: 1.5rem;
}

#detalleSubsidioModal .card-body {
    padding: 1rem;
}

#detalleSubsidioModal .row.g-3 {
    --bs-gutter-y: 0.75rem;
}

/* Badge in modal */
#detalle-estado .badge {
    font-size: 0.8rem;
    padding: 0.4em 0.8em;
}

/* Responsive improvements */
@media (max-width: 768px) {
    .modal-lg {
        max-width: 95%;
        margin: 1rem auto;
    }
    
    #detalleSubsidioModal .modal-body {
        padding: 1rem;
    }
    
    .modal-body .col-md-6 {
        margin-bottom: 1rem;
    }
    
    /* Mobile table adjustments */
    .subsidies-table-body .table-responsive {
        max-height: 50vh;
    }
    
    .subsidies-table .btn-group {
        flex-direction: column;
        gap: 2px;
    }
    
    .subsidies-table .btn-group .btn {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }
    
    /* Hide some columns on mobile to make room */
    .subsidies-table th:nth-child(4),
    .subsidies-table td:nth-child(4),
    .subsidies-table th:nth-child(7),
    .subsidies-table td:nth-child(7) {
        display: none;
    }
}

@media (max-width: 576px) {
    .subsidies-table th:nth-child(6),
    .subsidies-table td:nth-child(6) {
        display: none;
    }
}

/* DataTables specific improvements */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin: 0.5rem 0;
}

.dataTables_wrapper .dataTables_filter input {
    border-radius: var(--border-radius);
    border: 1px solid #dee2e6;
    padding: 0.375rem 0.75rem;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: var(--border-radius);
    border: 1px solid #dee2e6;
    padding: 0.375rem 0.75rem;
}

/* Pagination improvements */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--border-radius) !important;
    margin: 0 2px;
    border: 1px solid #dee2e6 !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}

/* Table container improvements */
.subsidies-table-card {
    width: 100%;
}

.subsidies-table-card .card-body {
    padding: 0;
}

.subsidies-table-body {
    padding: 1rem;
    width: 100%;
}

.subsidies-table-body .table-responsive {
    width: 100%;
}

/* Force table to use full width */
#subsidiosTable_wrapper {
    width: 100% !important;
}

#subsidiosTable {
    width: 100% !important;
    max-width: none !important;
}

/* Ensure container uses full width */
.subsidies-container {
    width: 100%;
    max-width: none;
}

/* Metric Cards for Reports */
.metric-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease;
}

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

.metric-card-body {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.metric-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    color: var(--dark-color);
}

.metric-label {
    color: #6c757d;
    margin: 0;
    font-size: 0.875rem;
}

.metric-change {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.metric-change.positive { color: var(--success-color); }
.metric-change.negative { color: var(--danger-color); }
.metric-change.neutral { color: #6c757d; }

/* Summary Card */
.summary-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.summary-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.summary-card-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-color);
}

.summary-card-body {
    padding: 0;
}

/* Insights Card */
.insights-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.insights-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.insights-card-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-color);
}

.insights-card-body {
    padding: 1.5rem;
}

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.insight-item:last-child {
    margin-bottom: 0;
}

.insight-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    color: white;
    flex-shrink: 0;
}

.insight-icon.success { background: var(--success-color); }
.insight-icon.warning { background: var(--warning-color); }
.insight-icon.info { background: var(--info-color); }

.insight-content {
    flex: 1;
}

.insight-text {
    margin: 0 0 0.25rem 0;
    font-size: 0.875rem;
    font-weight: 500;
}

.insight-meta {
    color: #6c757d;
    font-size: 0.75rem;
}

/* Profile Cards */
.profile-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.profile-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.profile-card-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-color);
}

.profile-card-body {
    padding: 1.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .page-header {
        padding: 1rem 1.5rem;
    }
    
    .page-actions {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    
    .stats-card-body {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .metric-card-body {
        flex-direction: column;
        text-align: center;
    }
}

/* Animation utilities */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Custom scrollbar */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}