/* --- VARIABLES --- */
:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f1c40f;
    --light-gray: #ecf0f1;
    --dark-gray: #7f8c8d;
    --text-color: #333;
    --sidebar-width: 250px;
}

/* --- RESET & GLOBAL --- */
body {
    font-family: 'Roboto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f6f9;
    color: var(--text-color);
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* --- LAYOUT --- */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: margin-left 0.3s;
}

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--secondary-color);
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: auto;
    transition: transform 0.3s;
    z-index: 1000;
}

.sidebar-header {
    padding: 20px;
    background-color: #1a252f;
    text-align: center;
}

.sidebar-header h2 {
    color: #fff;
    margin: 0;
    font-size: 1.5rem;
}

.sidebar-menu li {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: #bdc3c7;
    transition: all 0.3s;
}

.sidebar-menu a:hover, .sidebar-menu a.active {
    background-color: #34495e;
    color: #fff;
    border-left: 4px solid var(--primary-color);
}

.sidebar-menu i {
    margin-right: 15px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px;
    text-align: center;
    color: #7f8c8d;
    font-size: 0.8rem;
    position: absolute;
    bottom: 0;
    width: 100%;
}

/* --- MOBILE TOGGLE --- */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background-color: var(--secondary-color);
    color: #fff;
    border: none;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 999;
}

/* --- FORMS --- */
.form-container {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-width: 500px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--secondary-color);
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
}

.filter-form {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.btn-filter {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* --- BUTTONS --- */
.btn-submit {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    width: 100%;
    transition: background 0.3s;
}

.btn-submit:hover {
    background-color: #2980b9;
}

.btn-copy, .btn-close {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    margin-left: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-copy:hover, .btn-close:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-copy { background-color: var(--primary-color); color: white; }
.btn-close { background-color: var(--danger-color); color: white; }

/* --- ALERTS --- */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    color: white;
    font-weight: 500;
}
.alert-success { background-color: var(--success-color); }
.alert-danger { background-color: var(--danger-color); }

/* --- TABLES --- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    background-color: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

th {
    background-color: var(--secondary-color);
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--primary-color);
}

tr:hover { background-color: #f8f9fa; }

.table-list li { margin-bottom: 4px; }

/* --- LOGIN PAGE --- */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.login-card {
    background-color: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
    transition: transform 0.3s ease;
}

.login-card:hover { transform: translateY(-5px); }

.login-header { margin-bottom: 30px; }
.login-header h2 { color: var(--secondary-color); margin: 0; font-size: 1.8rem; font-weight: 700; }
.login-header p { color: var(--dark-gray); margin-top: 5px; font-size: 0.9rem; }

.input-group { position: relative; margin-bottom: 20px; text-align: left; }
.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #bdc3c7;
    transition: color 0.3s;
}

.input-group input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.3s, box-shadow 0.3s;
    background-color: #f9f9f9;
}

.input-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    outline: none;
    background-color: #fff;
}
.input-group input:focus + i { color: var(--primary-color); }

.btn-login {
    background-color: var(--primary-color);
    color: white;
    padding: 12px;
    border: none;
    border-radius: 6px;
    width: 100%;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
    margin-top: 10px;
    box-shadow: 0 4px 6px rgba(52, 152, 219, 0.2);
}

.btn-login:hover {
    background-color: #2980b9;
    box-shadow: 0 6px 10px rgba(52, 152, 219, 0.3);
    transform: translateY(-1px);
}

/* --- PASSWORD TOGGLE --- */
.password-wrapper { position: relative; }
.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--dark-gray);
    z-index: 2;
}

/* --- MODALS --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close-modal {
    font-weight: bold;
    position: absolute;
    right: 15px;
    top: 15px;
    cursor: pointer;
    font-size: 1.5rem;
}

.modal-textarea {
    width: 100%;
    height: 150px;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
    box-sizing: border-box;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.btn-modal {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}
.btn-cancel { background-color: #95a5a6; color: white; }
.btn-confirm { background-color: var(--danger-color); color: white; }

#textModal .modal-content { max-width: 700px; }
#textModal .modal-textarea { height: 400px; }

/* --- TABS --- */
.tabs {
    overflow: hidden;
    border-bottom: 2px solid #ddd;
    margin-bottom: 20px;
}

.tab-button {
    background-color: transparent;
    float: left;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 14px 20px;
    transition: 0.3s;
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark-gray);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab-button:hover {
    color: var(--primary-color);
    background-color: #f1f1f1;
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
}

.tab-content {
    display: none;
    animation: fadeEffect 0.5s;
}

.tab-content.active {
    display: block;
}

@keyframes fadeEffect {
    from {opacity: 0;}
    to {opacity: 1;}
}

/* --- TABLE SPECIFIC --- */
.tabla-renovaciones {
    width: 100%;
}

.row-danger td { background-color: #ffebee !important; }
.row-warning td { background-color: #fff8e1 !important; }

.table-list {
    margin: 0;
    padding-left: 15px;
}

/* --- ACTION BUTTONS & BADGES --- */
.btn-whatsapp {
    background-color: #25D366;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.3s;
    width: fit-content;
}
.btn-whatsapp:hover { background-color: #1da851; }

.btn-pendiente {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: fit-content;
}
.btn-pendiente:hover { background-color: #34495e; }

.btn-revert {
    background-color: var(--warning-color);
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: fit-content;
}
.btn-revert:hover { background-color: #f39c12; }

.badge-pagado {
    display: inline-block;
    padding: 6px 10px;
    background-color: var(--success-color);
    color: white;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* --- KPI DASHBOARD --- */
.kpi-container {
    display: flex;
    flex-wrap: nowrap; /* Force single row */
    gap: 15px; /* Reduce gap */
    margin-bottom: 30px;
    overflow-x: auto; /* Allow scroll on very small screens just in case */
    padding-bottom: 5px; /* Space for scrollbar if needed */
}

.kpi-card {
    background-color: #fff; /* Default fallback */
    border-radius: 8px;
    padding: 15px; /* Compact padding */
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    flex: 1;
    min-width: 150px; /* Smaller min-width to fit 5 items */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center; /* Center items horizontally */
    text-align: center; /* Center text */
    border: none; /* Remove border */
    color: #fff; /* Default text to white for colored cards */
    transition: transform 0.2s;
}

.kpi-card:hover { transform: translateY(-3px); }

/* Color variants - Backgrounds */
.kpi-card.success { background-color: var(--success-color); }
.kpi-card.danger { background-color: var(--danger-color); }
.kpi-card.warning { background-color: var(--warning-color); }
.kpi-card.info { background-color: var(--primary-color); }
.kpi-card.primary { background-color: #9b59b6; }

/* Text colors adjustment inside colored cards */
.kpi-card .kpi-title {
    color: rgba(255,255,255,0.9);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.kpi-card .kpi-title i { opacity: 0.8; }

.kpi-card .kpi-value {
    font-size: 1.4rem; /* Slightly smaller */
    font-weight: 700;
    color: #fff;
}

.kpi-card .kpi-alert {
    font-size: 0.8rem;
    margin-top: 5px;
    font-weight: 500;
    color: rgba(255,255,255,0.9);
}

/* Remove the specific text color classes inside cards if they clash, or override them */
.kpi-card .text-danger,
.kpi-card .text-warning,
.kpi-card .text-success,
.kpi-card .text-muted {
    color: #fff !important; /* Force white text on colored backgrounds */
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .sidebar-overlay.active {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .mobile-menu-toggle {
        display: block;
    }
    
    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .btn-filter {
        width: 100%;
    }
}
