:root {
    --bg-color: #0d0f14;
    --sidebar-bg: #14171d;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #64748b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --card-bg: #1e293b;
    --danger: #ef4444;
    --success: #10b981;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

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

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

/* Screens */
.screen {
    display: none !important;
    height: 100vh;
}

.screen.active {
    display: flex !important;
}

/* Auth Screen */
#auth-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at top right, #1e293b, #0d0f14);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

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

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.btn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.hidden {
    display: none !important;
}

/* Main Screen Layout */
#main-screen {
    display: flex;
}

/* Sidebar */
.sidebar {
    width: 260px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border-right: 1px solid var(--glass-border);
}

.sidebar-header {
    margin-bottom: 2.5rem;
}

.sidebar-header .logo span {
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.75rem;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
}

.sidebar-nav li:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.sidebar-nav li.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary-color);
    font-weight: 600;
}

.nav-divider {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-top: 1.5rem !important;
    padding-bottom: 0.5rem !important;
    cursor: default !important;
    pointer-events: none;
}

.add-group-item {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
}

.add-group-item input {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    background: rgba(0,0,0,0.2);
}

.add-group-item button:hover {
    background: var(--primary-hover);
}

.back-to-vault {
    margin-top: 1rem;
    color: var(--primary-color) !important;
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.user-info span {
    font-size: 0.9rem;
    font-weight: 500;
}

#logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.6;
    transition: var(--transition);
}

#logout-btn:hover {
    opacity: 1;
}

.fav-btn.active {
    color: #fbbf24 !important;
    background: rgba(251, 191, 36, 0.1) !important;
}

/* Settings Page */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 2rem;
}

.settings-card {
    padding: 2rem;
    border-radius: 1.5rem;
}

.settings-card h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.progress-container {
    margin-top: 1.5rem;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

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

#re-encrypt-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.mfa-secret {
    background: rgba(0,0,0,0.3);
    padding: 1rem;
    border-radius: 0.5rem;
    font-family: monospace;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 2px;
    margin: 1rem 0;
    color: var(--primary-color);
    border: 1px dashed var(--primary-color);
}

/* Content Area */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

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

.search-bar {
    width: 100%;
    max-width: 500px;
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
}

.search-icon {
    margin-right: 0.75rem;
    opacity: 0.5;
}

.search-bar input {
    background: none;
    border: none;
    padding: 0.25rem 0;
}

.search-bar input:focus {
    box-shadow: none;
}

#add-new-btn {
    width: auto;
    padding: 0.75rem 1.5rem;
}

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

.vault-info h2 {
    font-size: 1.5rem;
}

#record-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

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

.record-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.record-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    border-color: var(--primary-color);
}

.record-logo {
    width: 40px;
    height: 40px;
    background: var(--glass-bg);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.record-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.record-title h4 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.record-title p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.record-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 5px;
}

.action-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
    color: var(--text-color);
}

.action-btn.link-btn {
    text-decoration: none;
}

.action-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

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

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

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.password-input-wrapper {
    position: relative;
    display: flex;
    gap: 0.5rem;
}

#generate-password {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 0 0.75rem;
    border-radius: 0.75rem;
    cursor: pointer;
}

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

.btn-secondary {
    background: var(--glass-bg);
    color: var(--text-primary);
}

/* Notifications */
.notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 2rem;
    border-radius: 0.75rem;
    background: var(--primary-color);
    color: white;
    font-weight: 500;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* View Modal Details */
.view-details {
    padding: 1.25rem 0;
}

.view-group {
    margin-bottom: 1.25rem;
}

.view-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.view-val {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem;
    border-radius: 0.75rem;
    font-size: 1rem;
    color: var(--text-color);
    border: 1px solid var(--glass-border);
    word-break: break-all;
    min-height: 1.2em;
}

.view-val-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.view-val-row .view-val {
    flex: 1;
}

.password-font {
    font-family: 'Monaco', 'Consolas', monospace;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 1.5px;
    background: rgba(79, 70, 229, 0.1);
}

/* Splash Screen */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 9999;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#splash-screen.active {
    display: flex;
}

.splash-container {
    text-align: center;
}

.splash-container p {
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.logo-spinner {
    position: relative;
    animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.spinner-dot {
    animation: spin-inner 1.5s infinite linear;
    transform-origin: center;
}

@keyframes spin-inner {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Mobile Optimization: Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px;
    padding: 0 1.25rem;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
    backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.03); /* Back to transparent glass */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    backdrop-filter: blur(4px);
}

/* Responsive Queries */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .header-brand {
        display: none !important; /* Hide redundant logo on mobile */
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100%;
        z-index: 999;
        width: 280px;
        transition: var(--transition);
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        margin-left: 0;
        padding: 90px 1.25rem 2rem; /* Increased for breathing room */
    }

    .record-actions {
        display: flex;
        gap: 0.4rem;
        flex-wrap: wrap; /* Allow grouping on mobile if needed */
        justify-content: flex-start;
    }

    .action-btn {
        width: 40px; /* Slightly larger for touch */
        height: 40px;
        flex-shrink: 0;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
        margin-bottom: 2rem;
    }

    .header-actions {
        width: 100%;
        flex-direction: column-reverse;
    }

    .search-bar {
        width: 100% !important;
    }

    .vault-grid {
        grid-template-columns: 1fr; /* Single column on mobile */
        gap: 1rem;
    }

    .record-card {
        padding: 1.25rem;
    }

    .auth-container {
        width: 95%;
        padding: 1.5rem;
    }

    .modal {
        width: 95%;
        margin: 1rem;
        padding: 1.25rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .notification {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        width: calc(100% - 2rem);
    }
}
