@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700;900&display=swap');

body {
    font-family: 'Inter', sans-serif;
    background-color: #111827;
    color: #e5e7eb;
    margin: 0;
    min-height: 100vh;
}

.container {
    padding: 20px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    box-sizing: border-box;
    /* Asegura que el padding no afecte el ancho total */
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    border-bottom: 1px solid #374151;
    padding-bottom: 20px;
}

header h1 {
    font-weight: 900;
    font-size: 2rem;
    color: #818cf8;
    margin: 0;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#username-display {
    font-weight: bold;
}

#logout-btn {
    background-color: #374151;
    /* Un gris oscuro que combina */
    color: white;
    border: 1px solid #4b5563;
    /* Borde sutil */
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    /* Transición más suave */
}

#logout-btn:hover {
    background-color: #ef4444;
    /* Rojo al pasar el ratón para indicar acción destructiva */
    border-color: #ef4444;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
    /* Sombra roja */
}

/* Formularios de Autenticación */
.auth-container {
    background-color: #1f2937;
    padding: 40px;
    border-radius: 16px;
    border: 1px solid #374151;
    max-width: 400px;
    margin: 40px auto;
}

.auth-form h2 {
    text-align: center;
    font-weight: 900;
    margin-top: 0;
    margin-bottom: 30px;
}

.auth-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 8px;
    border: 1px solid #4b5563;
    background-color: #374151;
    color: white;
    box-sizing: border-box;
}

.auth-form button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background-color: #6366f1;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.auth-form button:hover {
    background-color: #4f46e5;
}

.toggle-form {
    text-align: center;
    font-size: 0.9em;
    margin-top: 20px;
}

.toggle-form a {
    color: #818cf8;
    text-decoration: none;
    font-weight: bold;
}

/* Dashboard */
#dashboard-section h2 {
    border-bottom: 1px solid #374151;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.user-details {
    background-color: #1f2937;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 40px;
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.plan-card {
    background-color: #1f2937;
    border: 1px solid #374151;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
}

.plan-card h3 {
    margin-top: 0;
}

.plan-card .price {
    font-size: 2em;
    font-weight: 900;
    color: #818cf8;
    margin: 10px 0;
}

.plan-card .duration {
    color: #9ca3af;
    margin-bottom: 20px;
}

.plan-card button {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: none;
    background-color: #10b981;
    color: white;
    font-weight: bold;
    cursor: pointer;
}

/* Historial de Compras */
#history-container {
    background-color: #1f2937;
    border-radius: 12px;
    padding: 0;
    /* Quitamos el padding para que la tabla ocupe todo */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Scrolling más suave en iOS */
    margin-bottom: 40px;

    /* Para responsividad en móviles */
}

#history-container table {
    width: 100%;
    border-collapse: collapse;
    color: #e5e7eb;
}

#history-container th,
#history-container td {
    padding: 12px 15px;
    /* Un poco menos de padding para móviles */
    text-align: left;
    border-bottom: 1px solid #374151;
}

#history-container thead th {
    background-color: #374151;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.8em;
    letter-spacing: 0.05em;
    color: #9ca3af;
    white-space: nowrap;
    /* Evita que los títulos se partan */
}

#history-container tbody tr:last-child td {
    border-bottom: none;
}

#history-container tbody tr:hover {
    background-color: #374151;
}

.status {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: bold;
    text-transform: capitalize;
}

.status-approved {
    background-color: #10b981;
    /* Verde */
    color: #ffffff;
}

.status-pending,
.status-in_process {
    background-color: #f59e0b;
    /* Ámbar */
    color: #1f2937;
}

/* Utilidades */
.hidden {
    display: none;
    visibility: hidden;
    /* Añadido para asegurar que se oculte por completo */
}

.message {
    text-align: center;
    margin-top: 15px;
    font-weight: bold;
}

.error {
    color: #f87171;
}

.success {
    color: #4ade80;
}

/* --- Sección de Descarga de App y Modal --- */

.app-download-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto 20px auto;
    text-align: center;
}

.download-app-button {
    background: linear-gradient(45deg, #22d3ee, #0ea5e9);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 900;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(34, 211, 238, 0.3);
}

.download-app-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 211, 238, 0.4);
}

/* Estilos del Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    /* Lo haremos visible con JS */
    visibility: hidden;
    /* Clave para que no bloquee clics cuando está oculto */
    transition: opacity 0.3s ease;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
    /* Lo hacemos visible cuando no tiene la clase hidden */
}

.modal-content {
    background-color: #1f2937;
    padding: 30px 40px;
    border-radius: 16px;
    border: 1px solid #374151;
    width: 90%;
    max-width: 500px;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay:not(.hidden) .modal-content {
    transform: scale(1);
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: white;
}

.note {
    background-color: #374151;
    padding: 15px;
    border-radius: 8px;
    font-size: 0.9em;
    border-left: 4px solid #f59e0b;
}

.download-apk-button {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 20px;
    padding: 12px;
    border-radius: 8px;
    background-color: #10b981;
    color: white;
    font-weight: bold;
    text-decoration: none;
    transition: background-color 0.2s;
}

.download-apk-button:hover {
    background-color: #059669;
}

/* --- Media Queries para Responsividad --- */
@media (max-width: 768px) {
    .auth-container {
        padding: 25px;
        margin: 20px auto;
    }

    /* Hacemos la tabla del historial más legible en móviles */
    #history-container table {
        border: 0;
    }

    #history-container thead {
        display: none;
        /* Ocultamos los encabezados de la tabla */
    }

    #history-container tr {
        display: block;
        margin-bottom: 1rem;
        border-bottom: 2px solid #6366f1;
    }

    #history-container td {
        display: block;
        text-align: right;
        /* Alineamos el contenido a la derecha */
        border-bottom: 1px dotted #374151;
    }

    #history-container td::before {
        content: attr(data-label);
        /* Usamos el data-label como título */
        float: left;
        font-weight: bold;
        text-transform: uppercase;
        color: #9ca3af;
    }

    #history-container td:last-child {
        border-bottom: 0;
    }
}