/* ============================
   VARIABLES GLOBALES
   ============================ */
:root {
    --primary: #1A237E;
    --primary-dark: #0D1557;
    --accent: #00E676;
    --accent-dark: #00C853;
    --bg: #E0F2F1;
    --card-bg: #ffffff;
    --text: #2d3748;
    --text-light: #A0AEC0;
    --border: #e2e8f0;
}

/* ============================
   RESET BÁSICO
   ============================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

/* ============================
   ESTRUCTURA GENERAL
   ============================ */
body {
    font-family: system-ui, sans-serif;
    background: #f5f5f5;
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================
   CONTENEDOR PRINCIPAL
   ============================ */
.page-container {
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
    padding: 0 1rem 1rem 1rem;
}

/* ============================
   HEADER
   ============================ */
.header {
    background: linear-gradient(135deg, #1A237E 0%, #0D1557 100%);
    color: white;
    padding: 1rem;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-link {
    text-decoration: none;
    display: inline-block;
}

.header-link {
    color: white;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    transition: background 0.2s;
}

.header-link:hover {
    background: rgba(255,255,255,0.3);
}

.header-logo-svg {
    width: 48px;
    height: 48px;
}

.avatar-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
    padding: 0;
}

.avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-icon {
    color: #00E676;
    font-size: 1.5rem;
}

/* ============================
   MODAL DE USUARIO
   ============================ */
.user-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
}

.user-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-modal-content {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.user-modal-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: #e2e8f0;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    overflow: hidden;
}

.user-modal-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-modal-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2d3748;
}

.user-modal-email {
    color: #718096;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.user-modal-role {
    color: #667eea;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.user-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-modal-btn {
    padding: 0.875rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #5a67d8 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
}

.user-modal-btn.secondary {
    background: #e2e8f0;
    color: #2d3748;
}

.user-modal-btn.danger {
    background: #e53e3e;
    color: white;
}

.user-modal-btn.danger:hover {
    background: #c53030;
}

.submenu {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ============================
   TARJETAS (CARD)
   ============================ */
.card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* ============================
   BOTONES
   ============================ */
.btn {
    display: block;
    width: 100%;
    padding: 0.875rem;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-danger {
    background: #e53935;
    color: #fff;
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    width: auto;
}

/* ============================
   INPUTS Y FORMULARIOS
   ============================ */
.form-group {
    margin-bottom: 1rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.875rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 16px;
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    padding-right: 3rem;
}

.toggle-password {
    position: absolute;
    right: 0.875rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
}

.upload-buttons {
    display: flex;
    gap: 0.5rem;
}

.upload-buttons button {
    flex: 1;
}

.btn-green {
    background: #00C853 !important;
}

.btn-green:hover {
    background: #00E676 !important;
}

.btn-blue-border {
    background: transparent;
    border: 2px solid #1A237E;
    color: #1A237E;
}

.btn-blue-border:hover {
    background: #1A237E;
    color: white;
}

.btn-green-border {
    background: transparent;
    border: 2px solid #00C853;
    color: #00C853;
}

.btn-green-border:hover {
    background: #00C853;
    color: white;
}

.success-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #B2DFDB;
    border: 1px solid #80CBC4;
    border-radius: 12px;
    padding: 1rem;
    margin: 1rem 0;
    position: relative;
    color: #00695C;
    font-weight: bold;
    text-align: center;
}

.success-badge-close {
    position: absolute;
    right: 1rem;
    background: none;
    border: none;
    color: #455A64;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.error-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #FFEBEE;
    border: 1px solid #FFCDD2;
    border-radius: 12px;
    padding: 1rem;
    margin: 1rem 0;
    position: relative;
    color: #C62828;
    font-weight: bold;
    text-align: center;
}

.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.confirm-modal.active {
    display: flex;
}

.confirm-modal-content {
    background: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.confirm-modal-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: var(--text);
}

.confirm-modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.confirm-modal-buttons button {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: bold;
}

.confirm-modal-cancel {
    background: #e2e8f0;
    color: var(--text);
}

.confirm-modal-confirm {
    background: #C62828;
    color: white;
}

.image-preview {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    text-align: center;
    display: flex;
    justify-content: center;
}

.image-preview img {
    max-width: 300px;
    max-height: 200px;
    border-radius: 8px;
    object-fit: contain;
}

/* ============================
   BARRA DE PROGRESO
   ============================ */
.progress-container {
    margin-top: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

/* ============================
   TABLAS
   ============================ */
.invoices-table-wrapper {
    overflow-x: auto;
}

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

.invoices-table th,
.invoices-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* ============================
   BOTÓN ELIMINAR
   ============================ */
.delete-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    background: #e53935;
    color: #fff;
    border: none;
    cursor: pointer;
}

/* ============================
   ALERTAS
   ============================ */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #e6fffa;
    color: #065f46;
}

.alert-error {
    background: #ffe6e6;
    color: #8b0000;
}

/* ============================
   EMPTY STATES
   ============================ */
.empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-light);
}

/* ============================
   PERFIL DE USUARIO
   ============================ */
.avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-icon {
    font-size: 3rem;
    color: #A0AEC0;
}

/* ============================
   USER CARD
   ============================ */
.user-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.user-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-card-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.user-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

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

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    padding: 1rem;
    border-radius: 10px;
    width: 95%;
    max-width: 500px;
    margin: 0 auto;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #A0AEC0;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: #4A5568;
}

/* ============================
   HEADER AVATAR
   ============================ */
.header-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
}

.avatar-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================
   MEDIA QUERY ÚNICA
   ============================ */
@media (max-width: 480px) {

    .avatar-preview {
        width: 80px;
        height: 80px;
    }

    .btn-sm {
        width: 100%;
    }

    .modal-content {
        width: 95%;
        max-width: none;
    }
}

/* ============================
   LOGO DE LA APP (HEADER + LOGIN)
   ============================ */

/* --- Variables de Color y Configuración Base --- */
:root {
    --color-bg-app: #1A237E;
    --color-border-outer: #00C853;
    --color-doc: #E0F2F1;
    --color-scan-bar: #00E676;
    --color-text-lines: #A0AEC0;
}

.canvas {
    perspective: 1000px;
}

/* --- Contenedor Principal del Icono --- */
.app-icon {
    width: 200px;
    height: 200px;
    background-color: var(--color-bg-app);
    border-radius: 40px;
    box-shadow:
        0 0 0 8px var(--color-border-outer),
        0 10px 20px rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* --- El Documento/Papel --- */
.document {
    width: 120px;
    height: 150px;
    background-color: var(--color-doc);
    border-radius: 12px;
    position: relative;
    padding: 15px;
    box-sizing: border-box;
    box-shadow: inset 0 -5px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Pseudo-elemento para la esquina doblada */
.document::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--color-doc) 50%, rgba(255,255,255,0.8) 50%, rgba(0,0,0,0.1));
    border-bottom-left-radius: 12px;
    box-shadow: -2px 2px 5px rgba(0,0,0,0.1);
}

/* --- Líneas de Texto y Código de Barras --- */
.text-lines {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.text-lines.top {
    margin-top: 10px;
}

.line {
    height: 6px;
    background-color: var(--color-text-lines);
    border-radius: 3px;
    opacity: 0.6;
}

.line:nth-child(1) { width: 90%; }
.line:nth-child(2) { width: 80%; }
.line:nth-child(3) { width: 85%; }

.text-lines.bottom {
    margin-top: auto;
    flex-direction: row;
    justify-content: space-between;
    height: 40px;
}

.line-barcode {
    width: 4px;
    background-color: var(--color-text-lines);
    border-radius: 2px;
    opacity: 0.8;
}

/* --- La Barra de Escaneo Verde (con efecto de brillo) --- */
.scan-bar {
    position: absolute;
    top: 50%;
    left: -10px;
    width: calc(100% + 20px);
    height: 8px;
    background-color: var(--color-scan-bar);
    border-radius: 4px;
    box-shadow:
        0 0 5px var(--color-scan-bar),
        0 0 15px var(--color-scan-bar),
        0 0 30px rgba(0, 230, 118, 0.8);
    transform: translateY(-50%);
}

/* --- Versión mini para el header --- */
.app-icon-header {
    width: 48px;
    height: 48px;
}

/* --- Logo SVG para el header --- */
.header-logo-svg {
    width: 48px;
    height: 48px;
    display: block;
}

@media (max-width: 480px) {
    .header-logo-svg {
        width: 48px;
        height: 48px;
    }
}
