/* ========== VARIABLES Y RESET ========== */
:root {
    --primary-color: #970b0b;
    --secondary-color: #ce1313;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-bg: #1f2937;
    --light-bg: #f9fafb;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-primary);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========== LOGIN SCREEN ========== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #c41e3a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.login-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.login-box {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 50px;
    max-width: 400px;
    width: 90%;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header i {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 15px;
    display: block;
}

.login-header h1 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

#loginForm {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group-login {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group-login label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group-login input,
.form-group-login select {
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group-login input:focus,
.form-group-login select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(151, 11, 11, 0.1);
}

.btn-login {
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    margin-top: 10px;
}

.login-error {
    padding: 12px 15px;
    background: #fee;
    border: 1px solid var(--danger-color);
    border-radius: 8px;
    color: var(--danger-color);
    font-size: 14px;
    display: none;
    text-align: center;
}

.login-error.show {
    display: block;
}

.login-footer {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.login-footer p {
    margin: 5px 0;
}

.login-footer code {
    background: var(--light-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--primary-color);
}

/* ========== LAYOUT ========== */
.container-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
    height: auto;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 280px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #a0480d 100%);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
}

.logo-section {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.logo-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.logo-section h1 {
    font-size: 24px;
    margin-bottom: 5px;
    font-weight: 700;
}

.logo-section p {
    font-size: 12px;
    opacity: 0.8;
}

.nav-menu {
    list-style: none;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    padding-left: 20px;
}

.nav-link i {
    font-size: 18px;
    width: 20px;
}

.sidebar-footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 12px;
    opacity: 0.7;
}

/* ========== USER AREA ========== */
.user-area {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.user-details {
    flex: 1;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: white;
    margin: 0;
}

.user-role {
    font-size: 12px;
    opacity: 0.8;
    color: white;
    margin: 0;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: auto;
    min-height: 100vh;
}

.content-section {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    animation: fadeIn 0.3s ease;
    min-height: calc(100vh - 140px);
}

.content-section.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    font-size: 28px;
    color: var(--text-primary);
}

.section-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.report-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.report-controls select {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: white;
    cursor: pointer;
    font-size: 14px;
}

/* ========== BUTTONS ========== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: #d1d5db;
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
    padding: 8px 16px;
    font-size: 12px;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
    padding: 8px 16px;
    font-size: 12px;
}

.btn-warning:hover {
    background-color: #d90606;
}

.btn-sm {
    padding: 6px 12px !important;
    font-size: 11px !important;
}

/* ========== STATS GRID ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 15px;
    align-items: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
}

.stat-content h3 {
    font-size: 24px;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.stat-content p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ========== DASHBOARD GRID ========== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.dashboard-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.dashboard-card h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 16px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.payment-list,
.debtors-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.payment-item,
.debtor-item {
    padding: 12px;
    background: var(--light-bg);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--primary-color);
}

.debtor-item {
    border-left-color: var(--danger-color);
}

.pos-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pos-item {
    padding: 12px;
    background: var(--light-bg);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid #059669;
}

.pos-item-name {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pos-item-name strong {
    color: var(--text-primary);
}

.pos-item-name small {
    color: var(--text-secondary);
    font-size: 12px;
}

.pos-item-monto {
    font-weight: bold;
    color: #059669;
    font-size: 16px;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
    font-style: italic;
}

/* ========== SEARCH BAR ========== */
.search-bar {
    position: relative;
    margin-bottom: 20px;
}

.search-bar input {
    width: 100%;
    padding: 12px 15px 12px 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-bar i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* ========== TABLES ========== */
.table-responsive {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: auto;
    box-shadow: var(--shadow);
    max-height: none;
}

.table-scroll-y {
    max-height: 420px;
    overflow-y: auto;
    overflow-x: auto;
}

.table-scroll-both {
    max-height: 420px;
    overflow: auto;
}

/* Estilos para scrollbar */
.table-responsive::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: var(--light-bg);
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #6d28d9;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.data-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.data-table tbody tr {
    transition: background-color 0.3s ease;
}

.data-table tbody tr:hover {
    background-color: var(--light-bg);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.empty-row td {
    text-align: center;
    color: var(--text-secondary);
    padding: 30px 15px;
}

.text-center {
    text-align: center;
}

/* ========== PAGINACIÓN ========== */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 15px;
    background: var(--light-bg);
    border-radius: 8px;
    gap: 20px;
}

.pagination-info {
    font-weight: 500;
    color: var(--text-primary);
    min-width: 150px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pagination-controls button {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 4px;
}

.pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-numbers {
    display: flex;
    gap: 5px;
    align-items: center;
}

.page-number {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.page-number:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-number.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ========== INVENTORY GRID ========== */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.inventory-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: all 0.3s ease;
}

.inventory-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.inventory-card h3 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

.inventory-card .stock-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-weight: 600;
    margin: 10px 0;
}

.inventory-card .stock-warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #d97706 100%);
}

.inventory-card .stock-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #dc2626 100%);
}

.inventory-card .price {
    font-size: 18px;
    color: var(--primary-color);
    font-weight: 700;
    margin: 10px 0;
}

.inventory-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
    justify-content: center;
}

/* ========== MODALS ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-small {
    max-width: 350px;
}

.modal-large {
    max-width: 700px;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

/* ========== FORMS ========== */
.form-group {
    margin: 15px 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Form Section for organizing form content */
.form-section {
    margin: 20px;
    padding: 15px;
    background: rgba(99, 102, 241, 0.05);
    border-left: 4px solid var(--primary-color);
    border-radius: 8px;
}

.form-section h3 {
    margin: 0 0 15px 0;
    color: var(--text-primary);
    font-size: 16px;
}

/* Form Row for inline form groups */
.form-row {
    display: flex;
    gap: 15px;
    margin: 0;
}

.form-row .form-group {
    flex: 1;
    margin: 0;
}

/* ========== REPORT SUMMARY ========== */
.report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.report-item {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.report-item span {
    color: var(--text-secondary);
    font-weight: 500;
}

.report-item strong {
    font-size: 20px;
    color: var(--primary-color);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
    .sidebar {
        width: 250px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    .container-wrapper {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 15px;
    }

    .logo-section {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
    }

    .logo-icon {
        font-size: 32px;
        margin-bottom: 0;
    }

    .logo-section h1 {
        font-size: 18px;
        margin-bottom: 0;
    }

    .logo-section p {
        display: none;
    }

    .nav-menu {
        display: flex;
        gap: 5px;
        flex: 1;
        margin-left: 20px;
    }

    .nav-link {
        padding: 10px;
        margin-bottom: 0;
    }

    .sidebar-footer {
        display: none;
    }

    .main-content {
        overflow-y: auto;
    }

    .content-section {
        padding: 20px;
    }

    .section-header h2 {
        font-size: 22px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .table-responsive {
        overflow-x: auto;
    }

    .data-table th,
    .data-table td {
        padding: 10px;
        font-size: 12px;
    }

    .modal-content {
        width: 95%;
    }

    .report-controls {
        flex-direction: column;
        width: 100%;
    }

    .report-controls select,
    .btn {
        width: 100%;
    }

    .inventory-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ========== UTILITIES ========== */
.text-success {
    color: var(--success-color);
}

.text-warning {
    color: var(--warning-color);
}

.text-danger {
    color: var(--danger-color);
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-paid {
    background-color: #d1fae5;
    color: #065f46;
}

.status-pending {
    background-color: #fef3c7;
    color: #92400e;
}

.debt-positive {
    color: #dc2626;
    font-weight: bold;
}

.debt-zero {
    color: #059669;
    font-weight: bold;
}

.report-row-grouped {
    background-color: #f9fafb;
}

.report-row-grouped:hover {
    background-color: #f3f4f6;
}

.pos-item-reportes {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid #e5e7eb;
    font-size: 12px;
}

.pos-item-reportes:last-child {
    border-bottom: none;
}

.pos-item-reportes span:first-child {
    font-weight: 500;
    color: #374151;
    flex: 1;
}

.pos-monto {
    color: #059669 !important;
    font-weight: bold;
    white-space: nowrap;
    margin-left: 8px;
}

.pos-total-reportes {
    display: block;
    background: #f0fdf4;
    border: 2px solid #059669;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 8px;
    text-align: center;
    color: #059669;
    font-size: 14px;
    font-weight: bold;
}

.pos-detalles-reportes {
    max-height: 120px;
    overflow-y: auto;
    padding: 4px 0;
}

.hidden {
    display: none !important;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ========== TABS ========== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ========== CSV PREVIEW ========== */
#csvPreviewTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 14px;
}

#csvPreviewTable thead {
    background-color: var(--light-bg);
}

#csvPreviewTable th,
#csvPreviewTable td {
    padding: 10px;
    text-align: left;
    border: 1px solid var(--border-color);
}

#csvPreviewTable tbody tr:hover {
    background-color: var(--light-bg);
}

.btn-info {
    background-color: #3b82f6;
    color: white;
}

.btn-info:hover {
    background-color: #2563eb;
}

/* ========== POS - SISTEMA DE VENTAS ========== */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    max-width: 1400px;
}

@media (max-width: 1024px) {
    .pos-container {
        grid-template-columns: 1fr;
    }
}

.pos-section {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.pos-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
}

.pos-header h3 {
    margin: 0;
    font-size: 24px;
    color: var(--primary-color);
    font-weight: 700;
}

.pos-header p {
    margin: 5px 0 0 0;
    color: var(--text-secondary);
    font-size: 16px;
}

.form-group-pos {
    margin-bottom: 15px;
}

.form-group-pos label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group-pos input,
.form-group-pos select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group-pos input:focus,
.form-group-pos select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.pos-add-product {
    display: grid;
    grid-template-columns: 1fr 150px 150px;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .pos-add-product {
        grid-template-columns: 1fr;
    }
}

.pos-summary {
    background-color: var(--light-bg);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-item.total {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    background-color: white;
    padding: 15px;
    margin: 10px -20px -20px -20px;
    border-radius: 0 0 8px 8px;
}

.pos-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.pos-actions .btn {
    flex: 1;
    min-width: 150px;
}

/* Estilos para imprimir recibo */
.print-recibo {
    display: none;
}

@media print {
    body * {
        display: none;
    }
    
    .print-recibo {
        display: block;
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
        padding: 20px;
        font-family: 'Courier New', monospace;
        font-size: 12px;
        line-height: 1.6;
    }
    
    .print-recibo * {
        display: block;
    }
}

.recibo-header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px dashed #000;
}

.recibo-titulo {
    font-size: 18px;
    font-weight: bold;
    margin: 0;
}

.recibo-subtitulo {
    font-size: 14px;
    color: #666;
    margin: 5px 0 0 0;
}

.recibo-separador {
    text-align: center;
    margin: 10px 0;
    color: #999;
}

.recibo-datos {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px dashed #000;
    font-size: 11px;
}

.recibo-dato {
    display: flex;
    justify-content: space-between;
    margin: 5px 0;
}

.recibo-tabla {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    border-top: 2px dashed #000;
    border-bottom: 2px dashed #000;
}

.recibo-tabla thead {
    font-weight: bold;
    border-bottom: 1px dashed #000;
}

.recibo-tabla th,
.recibo-tabla td {
    padding: 5px 0;
    text-align: right;
    font-size: 10px;
}

.recibo-tabla th:first-child,
.recibo-tabla td:first-child {
    text-align: left;
}

.recibo-total {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 2px dashed #000;
    text-align: right;
}

.recibo-total-item {
    display: flex;
    justify-content: space-between;
    margin: 5px 0;
    font-size: 11px;
}

.recibo-total-monto {
    font-size: 14px;
    font-weight: bold;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #000;
}

.recibo-footer {
    text-align: center;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 2px dashed #000;
    font-size: 10px;
    color: #666;
}

/* ========== MÓDULO DE GASTOS ========== */

.gastos-summary-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gasto-stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gasto-stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.gasto-stat-card:nth-child(2) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.2);
}

.gasto-stat-card:nth-child(2):hover {
    box-shadow: 0 8px 25px rgba(245, 87, 108, 0.3);
}

.gasto-stat-card:nth-child(3) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.2);
}

.gasto-stat-card:nth-child(3):hover {
    box-shadow: 0 8px 25px rgba(79, 172, 254, 0.3);
}

.stat-label {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
    margin-bottom: 10px;
    font-weight: 600;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 10px;
    word-break: break-word;
}

.stat-period {
    font-size: 12px;
    opacity: 0.85;
    font-style: italic;
}

.gastos-filters {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.filter-group select,
.filter-group input {
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(151, 11, 11, 0.1);
}

.filter-group input[type="date"] {
    min-width: 150px;
}

.gastos-filters .btn {
    margin-top: 8px;
}

#gastosFiltroPersonalizado {
    display: none;
    flex: 1;
    min-width: 300px;
    gap: 15px;
}

#gastosFiltroPersonalizado > div {
    display: flex;
    gap: 15px;
}

#gastosFiltroPersonalizado > div > div {
    flex: 1;
}

/* Mejoras para la tabla de gastos */
.content-section .table-responsive {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table {
    border-collapse: collapse;
    width: 100%;
}

.data-table thead {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    font-weight: 600;
}

.data-table th {
    padding: 15px;
    text-align: left;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr {
    transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
    background-color: #f9f9f9;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table .empty-row td {
    text-align: center;
    padding: 40px 15px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Estilos para botones de acciones */
.btn-sm {
    padding: 8px 12px;
    font-size: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.btn-sm i {
    font-size: 11px;
}

.btn-info {
    background-color: #3b82f6;
    color: white;
}

.btn-info:hover {
    background-color: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Responsive para gastos-filters */
@media (max-width: 768px) {
    .gastos-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .gastos-filters .btn {
        width: 100%;
        justify-content: center;
    }
    
    #gastosFiltroPersonalizado {
        flex-direction: column;
    }
    
    #gastosFiltroPersonalizado > div {
        flex-direction: column;
    }
    
    .gastos-summary-panel {
        grid-template-columns: 1fr;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px;
        font-size: 13px;
    }
    
    .stat-value {
        font-size: 24px;
    }
}

/* ========== RESPONSIVE COMPLETO - TABLET Y MÓVIL ========== */

/* Tablet Horizontal (1024px y menos) */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
        padding: 15px;
    }
    
    .logo-section h1 {
        font-size: 20px;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* Tablet Vertical (768px y menos) */
@media (max-width: 768px) {
    body {
        overflow: auto;
    }
    
    .container-wrapper {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }
    
    /* Sidebar se convierte en top bar */
    .sidebar {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 15px 20px;
        overflow-x: auto;
        height: auto;
    }
    
    .logo-section {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
        margin-right: 20px;
    }
    
    .logo-section h1 {
        font-size: 18px;
        margin-bottom: 0;
    }
    
    .logo-section p {
        display: none;
    }
    
    .logo-icon {
        display: none;
    }
    
    .nav-menu {
        display: flex;
        flex-direction: row;
        gap: 10px;
        overflow-x: auto;
        padding-bottom: 5px;
    }
    
    .nav-link {
        white-space: nowrap;
        padding: 10px 15px;
        margin-bottom: 0;
        font-size: 14px;
    }
    
    .nav-link:hover,
    .nav-link.active {
        padding-left: 15px;
    }
    
    .sidebar-footer {
        display: none;
    }
    
    .user-area {
        display: none;
    }
    
    /* Main content */
    .main-content {
        padding: 15px;
        height: auto;
        overflow: visible;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-number {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    /* Dashboard Grid */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Section Header */
    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .section-header h2 {
        font-size: 22px;
    }
    
    .section-header button,
    .section-header .btn {
        width: 100%;
    }
    
    /* Tables */
    .table-responsive {
        max-height: none;
        overflow-x: auto;
    }
    
    .data-table {
        font-size: 13px;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px 8px;
        font-size: 12px;
    }
    
    /* Action buttons */
    .action-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .action-buttons .btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    /* Forms */
    .form-group label {
        font-size: 13px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px;
        padding: 10px;
    }
    
    /* Modals */
    .modal-content {
        width: 95%;
        max-width: 500px;
        max-height: 90vh;
        overflow-y: auto;
        margin: 20px;
    }
    
    .modal-header h2 {
        font-size: 20px;
    }
    
    /* POS Container */
    .pos-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Inventory Grid */
    .inventory-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .inventory-card {
        padding: 15px;
    }
    
    .inventory-card h3 {
        font-size: 14px;
    }
    
    .price {
        font-size: 18px;
    }
    
    /* Report Controls */
    .report-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .report-controls select,
    .report-controls button {
        width: 100%;
    }
    
    /* Report Summary */
    .report-summary {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    /* Pagination */
    .pagination-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-numbers {
        flex-wrap: wrap;
    }
    
    /* Login Box */
    .login-box {
        padding: 30px 25px;
        max-width: 90%;
    }
    
    .login-header h1 {
        font-size: 22px;
    }
    
    .login-header i {
        font-size: 36px;
    }
}

/* Móvil Horizontal (667px y menos) */
@media (max-width: 667px) and (orientation: landscape) {
    .sidebar {
        padding: 10px 15px;
    }
    
    .nav-menu {
        gap: 5px;
    }
    
    .nav-link {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .main-content {
        padding: 10px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .stat-card {
        padding: 10px;
    }
    
    .stat-number {
        font-size: 18px;
    }
    
    .modal-content {
        max-height: 85vh;
    }
}

/* Móvil Vertical (480px y menos) */
@media (max-width: 480px) {
    .sidebar {
        padding: 10px 15px;
    }
    
    .logo-section h1 {
        font-size: 16px;
    }
    
    .nav-menu {
        gap: 5px;
    }
    
    .nav-link {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .nav-link i {
        display: none;
    }
    
    .main-content {
        padding: 10px;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
    
    .stat-number {
        font-size: 28px;
    }
    
    .stat-label {
        font-size: 13px;
    }
    
    /* Section Header */
    .section-header h2 {
        font-size: 20px;
    }
    
    .section-header p {
        font-size: 13px;
    }
    
    /* Buttons */
    .btn {
        padding: 10px 15px;
        font-size: 13px;
    }
    
    /* Search Bar */
    .search-bar input {
        font-size: 14px;
        padding: 10px 15px;
    }
    
    /* Tables */
    .data-table {
        font-size: 11px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 5px;
        font-size: 11px;
    }
    
    .data-table th {
        font-size: 10px;
    }
    
    /* Hide less important columns on mobile */
    .data-table th:nth-child(n+5),
    .data-table td:nth-child(n+5) {
        display: none;
    }
    
    /* Action buttons */
    .action-buttons .btn {
        padding: 5px 8px;
        font-size: 10px;
    }
    
    .action-buttons .btn i {
        font-size: 10px;
    }
    
    /* Inventory Grid */
    .inventory-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    /* Dashboard Cards */
    .dashboard-card {
        padding: 15px;
    }
    
    .dashboard-card h3 {
        font-size: 16px;
    }
    
    /* Payment Item */
    .payment-item,
    .debtor-item,
    .pos-item {
        font-size: 13px;
        padding: 10px;
    }
    
    /* POS Section */
    .pos-header h3 {
        font-size: 18px;
    }
    
    .form-group-pos label {
        font-size: 12px;
    }
    
    .form-group-pos input,
    .form-group-pos select {
        font-size: 13px;
        padding: 8px;
    }
    
    /* Modals */
    .modal-content {
        width: 95%;
        padding: 15px;
        margin: 10px;
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 15px;
        margin: -15px -15px 15px -15px;
    }
    
    .modal-header h2 {
        font-size: 18px;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    /* Login Box */
    .login-box {
        padding: 25px 20px;
    }
    
    .login-header h1 {
        font-size: 20px;
    }
    
    .login-header i {
        font-size: 32px;
    }
    
    .btn-login {
        font-size: 15px;
        padding: 12px;
    }
}

/* Extra pequeño (375px y menos) */
@media (max-width: 375px) {
    .logo-section h1 {
        font-size: 14px;
    }
    
    .nav-link {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .main-content {
        padding: 8px;
    }
    
    .section-header h2 {
        font-size: 18px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-number {
        font-size: 24px;
    }
    
    .data-table {
        font-size: 10px;
    }
    
    .data-table th,
    .data-table td {
        padding: 6px 4px;
        font-size: 10px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .modal-content {
        padding: 12px;
    }
    
    .modal-header h2 {
        font-size: 16px;
    }
}

/* Mejoras de touch para dispositivos móviles */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-link,
    .action-buttons .btn,
    .inventory-card button {
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation;
    }
    
    .nav-link {
        padding: 12px 15px;
    }
    
    input,
    select,
    textarea,
    button {
        font-size: 16px !important; /* Evita zoom en iOS */
    }
    
    /* Mejorar área táctil de checkboxes y radios */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 20px;
        min-height: 20px;
    }
    
    /* Scroll suave en tablas */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Mejor feedback táctil */
    .btn:active,
    .nav-link:active,
    .action-buttons .btn:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
}

/* Landscape mode optimizations */
@media (orientation: landscape) and (max-height: 600px) {
    .sidebar {
        padding: 8px 15px;
    }
    
    .logo-section {
        margin-right: 15px;
    }
    
    .nav-link {
        padding: 6px 10px;
    }
    
    .main-content {
        padding: 10px;
    }
    
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .section-header {
        margin-bottom: 15px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Prevenir zoom en inputs en iOS */
@supports (-webkit-touch-callout: none) {
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Ocultar scrollbar en móviles pero mantener funcionalidad */
@media (max-width: 768px) {
    .sidebar::-webkit-scrollbar,
    .nav-menu::-webkit-scrollbar {
        display: none;
    }
    
    .sidebar,
    .nav-menu {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

/* Ajustes para notch de iPhone X y superiores */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .sidebar {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
}

/* Refuerza alturas de scroll en tablas críticas */
.table-scroll-y,
.table-scroll-both {
    max-height: 420px;
}

@media (max-width: 768px) {
    .table-scroll-y,
    .table-scroll-both {
        max-height: calc(100vh - 280px);
    }
}

/* Transiciones suaves para cambios de orientación */
@media (prefers-reduced-motion: no-preference) {
    * {
        transition: all 0.3s ease;
    }
    
    .stats-grid,
    .dashboard-grid,
    .inventory-grid {
        transition: grid-template-columns 0.3s ease;
    }
}
