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

:root {
    --primary: #9d4edd;
    --primary-light: #c8b6ff;
    --accent: #3c096c;
    --bg-dark: #0f0c29;
    --bg-gradient: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8f9fa;
    --text-muted: #adb5bd;
    --glass-blur: blur(15px);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --success: #00f5d4;
    --error: #ff5d8f;
    --warning: #fee440;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

html {
    height: 100%;
    height: -webkit-fill-available;
}

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1, h2, h3, .brand {
    font-family: 'Outfit', sans-serif;
}

/* Glassmorphism Classes */
.glass {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--card-border);
    border-radius: 20px;
}

/* Auth Screen */
#auth-screen {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* dynamic viewport height - mobile friendly */
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-gradient);
    transition: opacity 0.5s ease;
    overflow: hidden;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Animated background orbs */
#auth-screen::before,
#auth-screen::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.25;
    pointer-events: none;
    animation: floatOrb 8s ease-in-out infinite alternate;
}

#auth-screen::before {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -150px;
    left: -100px;
}

#auth-screen::after {
    width: 400px;
    height: 400px;
    background: #3c096c;
    bottom: -100px;
    right: -100px;
    animation-delay: -4s;
}

@keyframes floatOrb {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(40px, 30px) scale(1.1); }
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    text-align: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
    animation: slideUp 0.6s ease;
    position: relative;
    z-index: 1;
    margin: 1rem;
}

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

.auth-card h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.input-group {
    margin-bottom: 1.5rem;
    position: relative;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.input-group input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 16px;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 15px rgba(157, 78, 221, 0.3);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(45deg, var(--accent), var(--primary));
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(157, 78, 221, 0.4);
}

/* Dashboard Layout */
#main-app {
    display: none;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--card-border);
    background: rgba(15, 12, 41, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100;
}

/* App body = sidebar + content */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ── Sidebar ── */
#sidebar {
    width: 260px;
    flex-shrink: 0;
    background: rgba(15, 12, 41, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    z-index: 200;
}

#sidebar.collapsed {
    width: 0;
    transform: translateX(-260px);
}

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 0 1.5rem;
    margin: 1rem 0 0.5rem;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
}

#sidebar.collapsed .sidebar-section-label {
    opacity: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 0.75rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.sidebar-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: var(--transition);
}

.sidebar-item:hover {
    background: rgba(157, 78, 221, 0.12);
    color: var(--text-main);
}

.sidebar-item:hover i {
    color: var(--primary-light);
}

.sidebar-item.active {
    background: rgba(157, 78, 221, 0.2);
    color: var(--primary-light);
    border: 1px solid rgba(157, 78, 221, 0.25);
}

.sidebar-item.active i {
    color: var(--primary-light);
}

.sidebar-item.danger:hover {
    background: rgba(255, 93, 143, 0.15);
    color: var(--error);
}

.sidebar-item.danger:hover i {
    color: var(--error);
}

.sidebar-spacer {
    flex: 1;
}

/* Overlay for mobile */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.35s ease;
}

#sidebar-overlay.visible {
    opacity: 1;
}

/* Hamburger button */
#menu-toggle {
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    color: white;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

#menu-toggle:hover {
    background: rgba(157, 78, 221, 0.2);
    border-color: var(--primary);
}

.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Scrollbar styling */
.app-content::-webkit-scrollbar { width: 4px; }
.app-content::-webkit-scrollbar-track { background: transparent; }
.app-content::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }


.vault-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-light);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Vault List */
.vault-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.vault-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.vault-item {
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.vault-item:hover {
    transform: translateY(-5px);
    border-color: var(--primary-light);
}

.item-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--primary-light);
}

.item-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.item-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* OTP Badge */
.otp-box {
    background: rgba(0, 245, 212, 0.1);
    border: 1px solid rgba(0, 245, 212, 0.3);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.otp-code {
    font-family: 'Outfit', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--success);
}

.otp-timer {
    width: 24px;
    height: 24px;
    position: relative;
}

.timer-svg {
    transform: rotate(-90deg);
}

.timer-circle {
    fill: none;
    stroke: var(--success);
    stroke-width: 2;
    stroke-dasharray: 63;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
}

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

/* Toast Notification */
#toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 3000;
}

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

@media (max-width: 768px) {
    /* On mobile, sidebar overlays the content instead of pushing it */
    #sidebar {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(-260px);
        width: 260px !important;
    }

    #sidebar:not(.collapsed) {
        transform: translateX(0);
    }
}

@media (max-width: 600px) {
    .app-content { padding: 1rem; gap: 1rem; }
    .vault-grid { grid-template-columns: 1fr; gap: 1rem; }
    .vault-stats { grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.3rem; }
    .auth-card { padding: 2rem 1.5rem; margin: 1rem; max-width: 100%; }
    .vault-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .vault-header .input-group { width: 100%; }
    .modal { padding: 1.5rem; margin: 0.5rem; }
    header { padding: 1rem; }
    header h1 { font-size: 1.3rem; }
    .hide-xs { display: none; }

    #auth-screen::before { width: 300px; height: 300px; }
    #auth-screen::after  { width: 250px; height: 250px; }
}
