/* public/css/style.css - Estilos Generales para el Sistema PerúCien Admin */

/* --- 1. Reseteo Básico y Tipografía --- */
body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f4f7fa;
    margin: 0;
    padding: 0;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- 2. Cabecera y Navegación --- */
.main-header {
    background-color: #2c3e50; /* Azul oscuro */
    color: #ecf0f1; /* Gris claro */
    padding: 15px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Para responsive */
    gap: 15px; /* Espacio entre logo y nav */
}

.main-header .logo {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    line-height: 1; /* Para alinear mejor */
}

.main-header .logo a {
    color: #ecf0f1;
    text-decoration: none;
    transition: color 0.3s ease;
}

.main-header .logo a:hover {
    color: #3498db; /* Azul más claro */
}

.main-nav {
    flex-grow: 1; /* Permite que ocupe espacio */
    text-align: right;
}

.main-nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Alinea los ítems a la derecha */
    flex-wrap: wrap; /* Para responsive */
    gap: 15px; /* Espacio entre ítems del menú */
}

.main-nav ul li {
    margin-left: 0; /* Reseteamos el margin-left que teníamos */
}

.main-nav ul li a {
    color: #ecf0f1;
    text-decoration: none;
    font-weight: 500;
    padding: 5px 0;
    transition: color 0.3s ease, border-bottom 0.3s ease;
}

.main-nav ul li a:hover,
.main-nav ul li a.active {
    color: #3498db;
    border-bottom: 2px solid #3498db;
}

.main-nav .user-info {
    display: flex;
    align-items: center;
    margin-left: 20px;
    color: #bdc3c7; /* Gris un poco más oscuro */
    font-size: 14px;
    white-space: nowrap; /* Evita que el texto de bienvenida se rompa */
}

.main-nav .user-info span {
    margin-right: 10px;
}

.btn-logout {
    background-color: #e74c3c; /* Rojo */
    color: white;
    padding: 8px 15px;
    border-radius: 4px;
    text-decoration: none;
    transition: background-color 0.3s ease;
    font-weight: 500;
    border: none;
    cursor: pointer;
}

.btn-logout:hover {
    background-color: #c0392b; /* Rojo más oscuro */
}

/* --- 3. Contenido Principal y Footer --- */
.main-content {
    padding: 30px 20px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-top: 30px;
    margin-bottom: 30px; /* Asegura espacio para el footer */
    min-height: calc(100vh - 200px); /* Ajusta según la altura del header/footer */
}

.main-footer {
    background-color: #2c3e50;
    color: #ecf0f1;
    text-align: center;
    padding: 20px 0;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
}

.main-footer p {
    margin: 0;
    font-size: 14px;
}

/* --- 4. Botones Genéricos --- */
.btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 5px;
    transition: all 0.2s ease-in-out;
    text-decoration: none;
}

.btn-sm { /* Botones más pequeños para las acciones */
    padding: 5px 10px;
    font-size: 0.85em;
    /* margin-left: 10px; */ /* Quitado para mejor control en flex/grid */
}

.btn-primary {
    color: #fff;
    background-color: #3498db;
    border-color: #3498db;
}

.btn-primary:hover {
    color: #fff;
    background-color: #2980b9;
    border-color: #2980b9;
}

.btn-secondary {
    color: #fff; /* Cambiado a blanco para mejor contraste */
    background-color: #6c757d;
    border-color: #6c757d;
}

.btn-secondary:hover {
    color: #fff;
    background-color: #5a6268;
    border-color: #545b62;
}

.btn-success {
    color: #fff;
    background-color: #2ecc71;
    border-color: #2ecc71;
}

.btn-success:hover {
    color: #fff;
    background-color: #27ae60;
    border-color: #27ae60;
}

.btn-info {
    color: #fff;
    background-color: #17a2b8;
    border-color: #17a2b8;
}

.btn-info:hover {
    color: #fff;
    background-color: #138496;
    border-color: #117a8b;
}

.btn-danger {
    color: #fff;
    background-color: #e74c3c;
    border-color: #e74c3c;
}

.btn-danger:hover {
    color: #fff;
    background-color: #c0392b;
    border-color: #c0392b;
}

.btn-danger-outline {
    color: #e74c3c;
    border: 1px solid #e74c3c;
    background-color: transparent;
}
.btn-danger-outline:hover {
    color: white;
    background-color: #e74c3c;
}

.btn-warning-outline {
    color: #f39c12;
    border: 1px solid #f39c12;
    background-color: transparent;
}
.btn-warning-outline:hover {
    color: white;
    background-color: #f39c12;
}

.btn-light {
    color: #333;
    background-color: #f8f9fa;
    border-color: #f8f9fa;
}

.btn-light:hover {
    color: #333;
    background-color: #e2e6ea;
    border-color: #dae0e5;
}


/* --- 5. Mensajes de Alerta --- */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-color: #bee5eb;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border-color: #ffeeba;
}


/* --- 6. Formularios Genéricos --- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 16px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

textarea.form-control {
    min-height: 90px;
    resize: vertical;
}

.help-block {
    color: #e74c3c;
    font-size: 13px;
    margin-top: 5px;
    display: block;
}

.has-error .form-control {
    border-color: #e74c3c;
}

/* --- 7. Estilos Específicos de Módulos --- */

/* Login (index.php) */
.wrapper {
    width: 400px;
    padding: 30px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
    /* Centrado en la página, ya definido en body con flex, pero reforzamos */
    margin: 50px auto; /* Para dar espacio si no hay flexbox en body */
}


/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.summary-card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    padding: 25px;
    text-align: center;
    transition: transform 0.2s ease-in-out;
}

.summary-card:hover {
    transform: translateY(-5px);
}

.summary-card h3 {
    color: #2c3e50;
    margin-top: 0;
    font-size: 1.3em;
    margin-bottom: 15px;
}

.summary-value {
    font-size: 2.2em;
    font-weight: 700;
    color: #3498db;
    margin: 0;
}

.alert ul {
    list-style: none;
    padding: 0;
}

.alert ul li {
    background-color: rgba(255,255,255,0.7);
    padding: 10px 15px;
    margin-bottom: 8px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.alert ul li strong {
    color: #2c3e50;
    margin-right: 10px;
}

/* Barra de acciones y búsqueda (Clientes, Contratos) */
.actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.search-form {
    display: flex;
    gap: 10px;
}

.search-input {
    min-width: 250px;
    padding: 8px 12px;
}

.search-button, .clear-search-button {
    padding: 8px 15px;
}

/* Tablas de Datos */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.data-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    font-size: 14px;
}

.data-table tbody tr:hover {
    background-color: #f0f0f0;
}

.data-table .actions {
    white-space: nowrap;
}

.data-table .actions a {
    margin-right: 5px;
}

/* Detalles del Contrato y Pagos */
.card-details {
    background-color: #fcfcfc;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.detail-row {
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #444;
}
.detail-row strong {
    color: #2c3e50;
    display: inline-block;
    min-width: 150px;
}
.detail-row span {
    font-weight: normal;
}

/* Formulario de Facturas */
.form-section {
    background-color: #fcfcfc;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px; /* Espacio entre secciones del formulario */
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.form-section h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #2c3e50;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-row:last-child {
    margin-bottom: 0;
}

#invoice-items-table {
    width: 100%;
    margin-top: 20px;
}

#invoice-items-table thead th,
#invoice-items-table tbody td {
    padding: 10px;
    vertical-align: middle;
}

#invoice-items-table tbody td:nth-child(1) { width: 45%; } /* Descripción */
#invoice-items-table tbody td:nth-child(2) { width: 10%; } /* Cantidad */
#invoice-items-table tbody td:nth-child(3) { width: 20%; } /* Precio Unitario */
#invoice-items-table tbody td:nth-child(4) { width: 15%; } /* Subtotal */
#invoice-items-table tbody td:nth-child(5) { width: 10%; text-align: center; } /* Acciones */

#invoice-items-table .item-description { width: 100%; }
#invoice-items-table .item-quantity { width: 100%; text-align: center; }
#invoice-items-table .item-unit-price { width: 100%; text-align: right; }
#invoice-items-table .item-subtotal { width: 100%; text-align: right; background-color: #f9f9f9; }

#invoice-items-table tfoot td {
    padding: 10px;
    font-size: 1.1em;
    background-color: #f0f3f6;
    border-top: 2px solid #ddd;
}

#invoice-items-table tfoot td.text-right {
    text-align: right;
    font-weight: bold;
    color: #2c3e50;
}

#invoice-items-table tfoot input.form-control {
    text-align: right;
    font-weight: bold;
    background-color: #e9ecef;
    border: none;
}

/* Vista de Factura (facturas_ver.php) */
.invoice-container {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.invoice-meta, .invoice-client-info {
    flex: 1;
    min-width: 300px;
    margin-right: 20px;
}

.invoice-meta p, .invoice-client-info p {
    margin-bottom: 8px;
    line-height: 1.4;
}

.invoice-meta strong, .invoice-client-info strong {
    color: #2c3e50;
    display: inline-block;
    min-width: 120px;
}

.invoice-client-info h4 {
    color: #3498db;
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px dashed #eee;
    padding-bottom: 5px;
}

.invoice-items-view thead th,
.invoice-items-view tbody td,
.invoice-items-view tfoot td {
    border: 1px solid #dee2e6;
    padding: 10px;
}

.invoice-items-view tfoot td {
    background-color: #e9ecef;
    font-weight: bold;
}

.invoice-notes {
    background-color: #f9f9f9;
    border: 1px dashed #ced4da;
    border-radius: 5px;
    padding: 15px;
    margin-top: 20px;
    color: #555;
}

.invoice-footer-actions {
    text-align: right;
    margin-top: 40px;
}

.invoice-footer-actions .btn {
    margin-left: 10px;
}

/* Calendario de Pagos */
.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.calendar-nav h3 {
    margin: 0;
    color: #ecf0f1;
    font-size: 1.8em;
}

.calendar-nav .btn {
    background-color: #3498db;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.calendar-nav .btn:hover {
    background-color: #2980b9;
}

.calendar-grid {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    overflow: hidden;
}

.calendar-table {
    width: 100%;
    border-collapse: collapse;
}

.calendar-table th, .calendar-table td {
    border: 1px solid #e0e0e0;
    padding: 10px;
    text-align: center;
    height: 120px;
    vertical-align: top;
    position: relative;
}

.calendar-table th {
    background-color: #f8f9fa;
    color: #555;
    font-weight: 600;
    padding: 15px 10px;
}

.calendar-day .day-number {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    text-align: left;
    margin-bottom: 5px;
}

.empty-day {
    background-color: #f0f0f0;
}

.today {
    background-color: #e6f7ff;
    border: 2px solid #3498db;
}

.has-payments {
    background-color: #ffe0b2;
}
.has-payments:hover {
    background-color: #ffcc80;
}

.payment-list {
    list-style: none;
    padding: 0;
    margin: 5px 0 0 0;
    font-size: 0.85em;
    text-align: left;
    max-height: 80px;
    overflow-y: auto;
}

.payment-list::-webkit-scrollbar {
    width: 5px;
}
.payment-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 5px;
}

.payment-list li {
    margin-bottom: 3px;
    line-height: 1.2;
}

.payment-list li a {
    color: #e74c3c;
    text-decoration: none;
    font-weight: bold;
    display: block;
    padding: 2px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.payment-list li a:hover {
    background-color: rgba(231, 76, 60, 0.1);
    color: #c0392b;
}

/* --- 8. Estilos Responsive Globales --- */
@media (max-width: 992px) {
    .main-header .container {
        flex-direction: column;
        text-align: center;
    }
    .main-nav {
        width: 100%;
        text-align: center;
        margin-top: 10px;
    }
    .main-nav ul {
        justify-content: center;
    }
    .main-nav .user-info {
        margin-top: 10px;
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }
    .main-content {
        padding: 20px 15px;
        margin-top: 20px;
        margin-bottom: 20px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .invoice-header {
        flex-direction: column;
    }
    .invoice-meta, .invoice-client-info {
        margin-right: 0;
        margin-bottom: 20px;
    }
    .invoice-client-info {
        margin-top: 0;
    }
}

@media (max-width: 768px) {
    .calendar-nav {
        flex-direction: column;
        gap: 10px;
    }
    .calendar-nav h3 {
        font-size: 1.5em;
    }
    .calendar-table th, .calendar-table td {
        padding: 5px;
        height: 100px; /* Ajustar altura para móvil */
        font-size: 0.9em;
    }
    .calendar-day .day-number {
        font-size: 1em;
    }
    .payment-list {
        font-size: 0.75em;
        max-height: 60px;
    }
    .actions-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    .search-form {
        width: 100%;
        margin-top: 10px;
    }
    .search-input {
        flex-grow: 1;
        min-width: auto;
    }
}

/* Estilos para impresión */
@media print {
    body {
        background-color: #fff;
    }
    .main-header, .main-footer, .btn, .alert, p.summary-value, h3.mt-40, .invoice-footer-actions, .main-content > p:first-of-type, .calendar-nav {
        display: none !important;
    }
    .wrapper {
        width: auto !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .invoice-container {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
    .invoice-header {
        display: flex; /* O block si prefieres en la impresión */
    }
    .invoice-meta, .invoice-client-info {
        margin-right: 0;
        min-width: auto;
    }
    .invoice-client-info {
        margin-top: 20px;
    }
    .main-content {
        margin-top: 0 !important;
        padding: 0 !important;
        min-height: auto !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }
}