/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: linear-gradient(135deg, #0B0F19 0%, #17123A 50%, #0F172A 100%);
    background-attachment: fixed;
    color: #F8FAFC;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    overflow-x: hidden;
}

/* Glassmorphism Container */
.glass-container {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 20px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), 
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-container.admin-width {
    max-width: 800px;
}

/* Typography & Headers */
h1 {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    background: linear-gradient(90deg, #00f2fe, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 0.95rem;
    color: #94A3B8;
    text-align: center;
    margin-bottom: 16px;
}

/* Form controls */
.form-group {
    margin-bottom: 20px;
    width: 100%;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #94A3B8;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 14px 16px;
    color: #FFFFFF;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.form-input:focus {
    border-color: #00f2fe;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.2);
}

.form-select {
    width: 100%;
    background: #0B0F19;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 14px 16px;
    color: #FFFFFF;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.form-select:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.2);
}

/* Buttons */
.btn {
    width: 100%;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    border: none;
    border-radius: 12px;
    padding: 16px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.5), 
                0 0 15px rgba(0, 242, 254, 0.2);
}

.btn:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: none;
    color: #F1F5F9;
    margin-top: 12px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.05);
}

/* User Profile Badge */
.profile-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 14px;
    border-radius: 50px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.profile-info {
    display: flex;
    flex-direction: column;
}

.profile-name {
    font-weight: 600;
}

.profile-role {
    font-size: 0.75rem;
    color: #00f2fe;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.logout-btn {
    background: transparent;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    font-size: 0.85rem;
    transition: color 0.3s;
}

.logout-btn:hover {
    color: #ef4444;
}

/* Viewport Logic */
.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

/* Daughter View Specifics */
.daughter-counters-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.daughter-counter-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    transition: all 0.3s ease;
}

.daughter-counter-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.daughter-counter-name {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #94A3B8;
    margin-bottom: 8px;
}

.daughter-counter-value {
    font-size: 3.5rem;
    font-weight: 800;
    color: #00f2fe;
    line-height: 1;
    text-shadow: 0 0 30px rgba(0, 242, 254, 0.4);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.daughter-counter-value.pulse {
    transform: scale(1.15);
}

.daughter-empty-state {
    text-align: center;
    padding: 32px 20px;
    color: #64748B;
}

.daughter-empty-state svg {
    margin-bottom: 12px;
    opacity: 0.4;
}

/* Admin View Specifics */
.admin-section {
    margin-top: 16px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.admin-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.counters-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Custom Scrollbar for list */
.counters-list::-webkit-scrollbar {
    width: 6px;
}

.counters-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
}

.counters-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.counters-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== User Group Card (Container for each user + their counters) ===== */
.user-group-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.user-group-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* User Header (Name + Email + Add Counter button) */
.user-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.user-group-info {
    display: flex;
    flex-direction: column;
}

.user-group-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: #F8FAFC;
}

.user-group-email {
    font-size: 0.8rem;
    color: #64748B;
    margin-top: 2px;
}

/* Inline Title Row for User Group Header */
.user-group-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-add-counter-mini {
    display: none; /* hidden on desktop */
    background: rgba(0, 242, 254, 0.08);
    border: 1px solid rgba(0, 242, 254, 0.2);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    color: #00f2fe;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.btn-add-counter-mini:hover {
    background: rgba(0, 242, 254, 0.25);
    border-color: rgba(0, 242, 254, 0.4);
    transform: scale(1.1);
}

.admin-menu-btn {
    background: transparent;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    display: none;
    padding: 6px;
    align-items: center;
    justify-content: center;
    transition: color 0.3s, transform 0.3s;
}

.admin-menu-btn:hover {
    color: #00f2fe;
    transform: rotate(45deg);
}

.btn-add-counter {
    background: rgba(0, 242, 254, 0.08);
    border: 1px solid rgba(0, 242, 254, 0.2);
    border-radius: 10px;
    padding: 7px 14px;
    color: #00f2fe;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.btn-add-counter:hover {
    background: rgba(0, 242, 254, 0.15);
    border-color: rgba(0, 242, 254, 0.4);
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.15);
    transform: translateY(-1px);
}

/* Nested Counter Items inside User Card */
.user-group-counters {
    padding: 8px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nested-counter-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.nested-counter-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.nested-counter-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #CBD5E1;
    min-width: 80px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nested-counter-label .counter-icon {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8b5cf6;
    flex-shrink: 0;
}

.counter-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.counter-val {
    font-size: 1.5rem;
    font-weight: 700;
    color: #00f2fe;
    min-width: 50px;
    text-align: center;
    transition: all 0.3s ease;
}

.btn-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: white;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.btn-circle:hover {
    background: #8b5cf6;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
    transform: scale(1.1);
}

.btn-circle.minus:hover {
    background: #ef4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

/* Empty state for a user with no counters */
.user-empty-counters {
    text-align: center;
    padding: 16px;
    color: #475569;
    font-size: 0.85rem;
    font-style: italic;
}

/* User Pre-authorization Section */
.add-user-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 12px;
    margin-bottom: 16px;
}

/* Alert Notification Banner */
.notification {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 14px 28px;
    border-radius: 30px;
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.notification.show {
    transform: translateX(-50%) translateY(0);
}

.notification.success {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.15);
}

.notification.error {
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.15);
}

/* Keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal Dialog Styles (Premium Glassmorphism) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 15, 25, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 450px;
    background: rgba(23, 18, 58, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 242, 254, 0.1);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.show .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #00f2fe;
    margin: 0;
    letter-spacing: -0.02em;
}

.close-btn {
    background: none;
    border: none;
    color: #94A3B8;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s ease, transform 0.2s ease;
}

.close-btn:hover {
    color: #ef4444;
    transform: scale(1.1);
}

/* Responsive tweaks */
@media (max-width: 768px) {
    body {
        padding-top: calc(env(safe-area-inset-top) + 10px) !important;
        padding-bottom: calc(env(safe-area-inset-bottom) + 10px) !important;
        background-color: #0B0F19; /* Exact top dark background color */
    }
    .glass-container {
        padding: 12px;
    }
    h1 {
        font-size: 1.75rem;
    }
    .daughter-counter-value {
        font-size: 2.8rem;
    }
    .counters-list {
        max-height: none;
        overflow-y: visible;
        padding-right: 0;
    }
    .nested-counter-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .counter-controls {
        width: 100%;
        justify-content: space-between;
    }
    .counter-val {
        font-size: 1.3rem;
        min-width: 40px;
    }
    .btn-circle {
        width: 36px;
        height: 36px;
    }

    /* 1. Elementos a eliminar por completo de la vista principal móvil */
    .admin-header,
    #admin-profile-email,
    #daughter-profile-email,
    .user-group-email {
        display: none !important;
    }

    /* 2. Elementos a ocultar detrás de un botón (Menú/Configuración) */
    .logout-btn,
    .preauth-container {
        display: none !important;
    }
    .admin-menu-btn {
        display: block !important;
    }

    /* 3. Rediseño del botón "Añadir contador" */
    .btn-add-counter {
        display: none !important;
    }
    .btn-add-counter-mini {
        display: flex !important;
    }

    /* 4. Cabecera del administrador y rol en una sola línea */
    .profile-info {
        flex-direction: row !important;
        align-items: center;
        gap: 6px;
    }
    .profile-role::before {
        content: "- ";
    }
    .user-group-header {
        padding: 10px 12px;
    }
}
