@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --bg-base: hsl(224, 71%, 4%);
    --bg-surface: hsl(222, 47%, 8%);
    --bg-card: hsla(223, 47%, 12%, 0.6);
    --border-color: hsla(217, 32%, 60%, 0.1);
    
    --primary: hsl(263, 90%, 65%);
    --primary-glow: hsla(263, 90%, 65%, 0.25);
    --secondary: hsl(190, 90%, 50%);
    --success: hsl(142, 72%, 45%);
    --success-glow: hsla(142, 72%, 45%, 0.2);
    --danger: hsl(350, 89%, 60%);
    --danger-glow: hsla(350, 89%, 60%, 0.2);
    --warning: hsl(38, 92%, 50%);
    
    --text-primary: hsl(210, 40%, 98%);
    --text-secondary: hsl(215, 20%, 75%);
    --text-muted: hsl(215, 16%, 50%);
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253, 100%, 15%, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, hsla(190, 100%, 15%, 0.15) 0px, transparent 50%),
        radial-gradient(at 50% 100%, hsla(263, 100%, 15%, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    font-family: var(--font-body);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Glassmorphism Container */
.glass-container {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
    background: hsl(222, 30%, 20%);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Auth Pages Layout */
.auth-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 2.5rem;
    border-radius: 24px;
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.auth-header {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 24px hsla(263, 90%, 65%, 0.3);
    font-size: 1.8rem;
    color: white;
}

.auth-title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Forms */
.form-group {
    position: relative;
    margin-bottom: 1.5rem;
    z-index: 1;
}

.form-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: var(--transition-smooth);
    font-size: 1.1rem;
}

.form-control {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.75rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
    background: rgba(15, 23, 42, 0.8);
}

.form-control:focus + .input-icon {
    color: var(--primary);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideDown 0.3s ease;
    position: relative;
    z-index: 1;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: hsl(350, 100%, 75%);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--success);
    color: hsl(142, 100%, 70%);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    z-index: 1;
    position: relative;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), hsl(263, 90%, 55%));
    color: white;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(0);
}

.auth-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-top: 2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-smooth);
}

.auth-link:hover {
    color: var(--secondary);
    text-decoration: underline;
}

/* Dashboard Layout */
.dashboard-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    padding: 1.25rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
}

.nav-title {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-badge {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-logout {
    padding: 0.5rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: hsl(350, 100%, 75%);
    border-radius: 20px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-logout:hover {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 12px var(--danger-glow);
}

/* Dashboard Main Content */
.main-content {
    flex: 1;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2.5rem;
}

.dashboard-title {
    font-size: 1.75rem;
    font-weight: 800;
}

.dashboard-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.btn-add {
    width: auto;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
}

/* Empty State */
.empty-state {
    padding: 4rem 2rem;
    text-align: center;
    border-radius: 24px;
    margin: 2rem 0;
}

.empty-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}

.empty-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.empty-desc {
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto 2rem;
}

/* Authenticator Cards Grid */
.authenticator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* Authenticator Card */
.auth-card-item {
    border-radius: 20px;
    padding: 1.75rem;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    border: 1px solid var(--border-color);
    transition: var(--transition-smooth);
    animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.auth-card-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
    border-color: var(--card-brand-glow, var(--primary));
}

.auth-card-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, var(--card-brand-glow, var(--primary-glow)) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1;
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: var(--card-brand-color, linear-gradient(135deg, var(--primary), var(--secondary)));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

.brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.brand-provider {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Dynamic Brand Configurations */
.brand-google {
    --card-brand-color: linear-gradient(135deg, #4285F4, #34A853);
    --card-brand-glow: rgba(66, 133, 244, 0.15);
}
.brand-github {
    --card-brand-color: linear-gradient(135deg, #24292e, #4f5d73);
    --card-brand-glow: rgba(79, 93, 115, 0.2);
}
.brand-discord {
    --card-brand-color: linear-gradient(135deg, #5865F2, #404eed);
    --card-brand-glow: rgba(88, 101, 242, 0.2);
}
.brand-facebook {
    --card-brand-color: linear-gradient(135deg, #1877F2, #0d5ec4);
    --card-brand-glow: rgba(24, 119, 246, 0.2);
}
.brand-binance {
    --card-brand-color: linear-gradient(135deg, #F3BA2F, #d69e16);
    --card-brand-glow: rgba(243, 186, 47, 0.15);
}

/* Card Body (Dynamic Code & Timer) */
.card-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1;
}

.otp-code-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.otp-code {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    line-height: 1;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.otp-code:hover {
    filter: brightness(1.2);
}

.otp-code.refreshing {
    opacity: 0.5;
    transform: scale(0.98);
}

/* Circle Progress Timer */
.timer-container {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.timer-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 4;
}

.timer-progress {
    fill: none;
    stroke: var(--card-brand-color, var(--primary));
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 126; /* 2 * PI * r (r=20) */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}

.timer-text {
    position: absolute;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* Card Actions */
.card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    z-index: 1;
}

.card-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: var(--transition-smooth);
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    text-decoration: none;
}

.card-action-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.card-action-btn.btn-copy-totp:hover {
    color: var(--secondary);
}

.card-action-btn.btn-backup-key:hover {
    color: var(--warning);
}

.card-action-btn.btn-delete-card:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Modern Toast Notification */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    color: white;
    padding: 0.85rem 1.25rem;
    border-radius: 12px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    pointer-events: auto;
    animation: toastIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast.hiding {
    animation: toastOut 0.3s ease forwards;
}

.toast-success {
    border-left: 4px solid var(--success);
}
.toast-error {
    border-left: 4px solid var(--danger);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 1.5rem;
}

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

.modal {
    width: 100%;
    max-width: 480px;
    border-radius: 24px;
    padding: 2.25rem;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 800;
}

.btn-close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close-modal:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Tooltips & Instructions */
.tooltip-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--border-color);
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.tooltip-icon {
    color: var(--secondary);
    font-size: 0.9rem;
    margin-top: 0.1rem;
}

/* Reveal Key backup component style */
.reveal-key-text {
    font-family: monospace;
    letter-spacing: 0.05em;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    color: var(--warning);
    font-weight: 600;
    font-size: 1.1rem;
    word-break: break-all;
    text-align: center;
    margin: 1.25rem 0;
}

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

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

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

@keyframes toastIn {
    from {
        transform: translateY(20px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes toastOut {
    to {
        transform: translateY(20px) scale(0.9);
        opacity: 0;
    }
}

/* Welcome Banner (Hidden by default on desktop) */
.welcome-banner {
    display: none;
}

/* Mobile responsive scaling */
@media (max-width: 640px) {
    body {
        background-size: cover;
        overflow-x: hidden;
    }
    
    .auth-wrapper {
        padding: 1rem;
    }
    
    .navbar {
        padding: 0.85rem 1rem;
        width: 100%;
        max-width: 100vw;
    }

    .nav-title {
        font-size: 1.05rem;
    }

    .nav-logo {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        border-radius: 8px;
    }

    .user-badge {
        display: none !important; /* Hide long email badge in header on mobile to prevent stretching */
    }

    .welcome-banner {
        display: flex; /* Show welcome banner with email inside main content on mobile */
        padding: 0.85rem 1rem;
        background: var(--bg-card);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border: 1px solid var(--border-color);
        border-radius: 14px;
        margin-bottom: 1.5rem;
        align-items: center;
        justify-content: flex-start;
        gap: 0.75rem;
    }

    .btn-logout {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .main-content {
        padding: 1.25rem 1rem;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1.25rem;
        margin-bottom: 1.5rem;
    }
    
    .dashboard-title {
        font-size: 1.5rem;
        text-align: center;
    }

    .dashboard-subtitle {
        text-align: center;
    }

    .btn-add {
        width: 100%;
        text-align: center;
        padding: 0.85rem;
    }
    
    .authenticator-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Card Item mobile scaling overrides */
    .auth-card-item {
        padding: 1.25rem !important;
        gap: 1rem !important;
        border-radius: 16px;
    }

    .brand-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.1rem !important;
        border-radius: 8px !important;
    }

    .brand-name {
        font-size: 0.95rem !important;
    }

    .otp-code {
        font-size: 1.85rem !important;
    }

    .timer-container {
        width: 40px;
        height: 40px;
    }

    .timer-text {
        font-size: 0.75rem;
    }

    .card-actions {
        padding-top: 0.85rem;
        gap: 0.25rem;
    }

    .card-action-btn {
        padding: 0.35rem 0.5rem !important;
        font-size: 0.75rem !important;
        gap: 0.25rem;
    }
    
    .auth-card {
        padding: 1.75rem 1.25rem;
    }
    
    .modal {
        padding: 1.5rem 1.25rem;
        border-radius: 16px;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
        gap: 0.75rem;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}
