:root {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.3);

    /* Spacing System */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
    width: 100%;
}

.app-main {
    padding: 2.5rem;
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

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

h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s ease;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.primary-btn:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.secondary-btn {
    background-color: transparent;
    color: var(--text-main);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.secondary-btn:hover {
    background-color: var(--surface-color);
}

.secondary-btn:disabled {
    cursor: not-allowed !important;
    pointer-events: auto;
}

.secondary-btn:disabled:hover {
    background-color: rgba(16, 185, 129, 0.15) !important;
}

.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.filter-btn {
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

.filter-btn:hover, .filter-btn.active {
    background: var(--surface-color);
    color: var(--text-main);
}

.filter-btn.active {
    box-shadow: inset 0 0 0 1px var(--border-color);
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--surface-color);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--border-color);
}

.modal:not(.hidden) .modal-content {
    transform: translateY(0);
}

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

.close-modal {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
}
.close-modal:hover {
    color: var(--text-main);
}

.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

input, textarea, select {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.loading-spinner {
    border: 3px solid rgba(255,255,255,0.1);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Login Styles */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.login-container.hidden {
    display: none;
}

.login-box {
    background: var(--surface-color);
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    text-align: center;
}

.login-header {
    margin-bottom: 2rem;
}

.login-box h2 {
    margin-bottom: 0.25rem;
    font-size: 1.8rem;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.login-box form {
    text-align: left;
    overflow: hidden;
    position: relative;
}

.login-slides-wrapper {
    display: flex;
    width: 200%;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-slide {
    width: 50%;
    flex-shrink: 0;
    box-sizing: border-box;
    padding: 0 4px;
    transition: opacity 0.4s ease;
}

.login-slide.slide-inactive {
    opacity: 0;
    pointer-events: none;
    height: 0;
    overflow: hidden;
}

#login-step-2 input {
    font-variant-numeric: tabular-nums;
}

.login-box button {
    width: 100%;
    justify-content: center;
    margin-top: 1.5rem;
}

.error-message {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(239, 68, 68, 0.2);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    text-align: center;
}

.error-message.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* ==========================================
   SIDEBAR & ADMIN DASHBOARD NAVIGATION
   ========================================== */

/* Burger Menu Button (default hidden on desktop) */
.burger-btn {
    background: transparent;
    color: var(--text-main);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.burger-btn:hover {
    background-color: var(--surface-color);
}
.burger-btn:focus-visible {
    outline: 2px solid var(--primary-color);
}

/* Sidebar Wrapper */
.app-sidebar {
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 90;
    overflow-y: auto;
}

/* Brand/Logo Area */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-main);
}

/* Navigation List */
.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0.75rem;
}
.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.nav-item {
    display: flex;
    flex-direction: column;
}

/* Navigation Links (Accordion Triggers) */
.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    color: var(--text-main);
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    text-align: left;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}
.nav-link-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.nav-icon {
    color: var(--text-muted);
    transition: color 0.15s ease;
}
.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
}
.nav-link:hover .nav-icon {
    color: var(--text-main);
}
.nav-link:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

/* Chevron Rotation */
.chevron-icon {
    color: var(--text-muted);
    transition: transform 0.2s ease;
}
.nav-link[aria-expanded="true"] .chevron-icon {
    transform: rotate(180deg);
}

/* Submenu Styling */
.submenu-list {
    list-style: none;
    margin-top: 0.25rem;
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: all 0.3s ease;
}
.submenu-list.hidden {
    display: none;
}
.submenu-link {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}
.submenu-link:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}
.submenu-link:focus-visible {
    outline: 2px solid var(--primary-color);
}

/* Active Menu Link State */
.submenu-link.active,
.submenu-link[aria-current="page"] {
    background-color: rgba(99, 102, 241, 0.08);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

/* Sidebar Footer (Aktionen & User Badge) */
.sidebar-footer {
    padding: 1.5rem 0.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.sidebar-btn {
    width: 100%;
    justify-content: center;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
}

/* User Badge */
.user-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
    border: 1px solid var(--border-color);
}
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    text-transform: uppercase;
}
.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.user-info .username {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-info .user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Hide header add task button on desktop because sidebar has it */
.header-add-task-btn {
    display: block;
}

/* ==========================================
   USER PROFILE MODAL STYLING
   ========================================== */
.profile-details {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.profile-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    background: rgba(255, 255, 255, 0.02);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.profile-avatar-large {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
    font-weight: 700;
    font-size: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}
.profile-meta h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-main);
}
.profile-role {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}
.profile-info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background: rgba(15, 23, 42, 0.4);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.info-item label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.info-item .value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-main);
}

/* Badges for status */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-badge.status-active {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.status-badge.status-inactive {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ==========================================
   RESPONSIVE MEDIA QUERIES
   ========================================== */
@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 240px 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        display: block; /* Disable Grid on mobile */
        position: relative;
    }

    .burger-btn {
        display: flex; /* Show Burger Button */
    }

    .app-main {
        padding: 1.5rem;
    }

    /* Off-canvas Sidebar for Mobile */
    .app-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    /* When Sidebar is Active (class added by JS) */
    .app-sidebar.active {
        transform: translateX(280px);
    }

    /* Sidebar Overlay */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(2px);
        z-index: 999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Show add task button in header on mobile */
    .header-add-task-btn {
        display: block;
    }
}

/* ==========================================
   2FA MODAL IMPROVEMENTS
   ========================================== */

/* Status Card */
.status-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    background: rgba(16, 185, 129, 0.08);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    border: 1.5px solid rgba(16, 185, 129, 0.3);
    margin-bottom: var(--spacing-lg);
}

.status-card svg {
    flex-shrink: 0;
}

.status-card-content {
    flex: 1;
}

.status-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--success-color);
    margin-bottom: 0.15rem;
}

.status-card-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* QR Code Container */
.qr-code-container {
    display: flex;
    justify-content: center;
    margin: var(--spacing-lg) 0;
}

.qr-code-wrapper {
    background: #ffffff;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.qr-code-wrapper img {
    display: block;
    max-width: 200px;
    width: 100%;
    height: auto;
}

/* Divider with text */
.divider-with-text {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin: var(--spacing-lg) 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.divider-with-text::before,
.divider-with-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
}

/* Secret Key Display */
.secret-key-group {
    margin: var(--spacing-lg) 0;
}

.secret-key-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
}

.secret-key-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: rgba(255, 255, 255, 0.03);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.secret-key-text {
    flex: 1;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Courier New', monospace;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    word-spacing: 0.5em;
    color: var(--text-main);
    overflow-wrap: break-word;
}

.copy-btn {
    flex-shrink: 0;
    background: transparent;
    color: var(--text-muted);
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: var(--surface-color);
    color: var(--text-main);
    border-color: var(--primary-color);
}

.copy-btn.copied {
    color: var(--success-color);
    border-color: var(--success-color);
}

/* Code Input Group (6 einzelne Inputs) */
.code-input-group {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
    margin: var(--spacing-md) 0;
}

.code-input {
    width: 3rem;
    height: 3.5rem;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
    color: var(--text-main);
    transition: all 0.2s ease;
}

.code-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    outline: none;
}

.code-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Info Box (Tipps, Hinweise) */
.info-box {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-md);
    margin: var(--spacing-lg) 0;
}

.info-box-icon {
    flex-shrink: 0;
    color: var(--primary-color);
}

.info-box-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Accordion für erweiterte Details */
.accordion-section {
    margin: var(--spacing-lg) 0;
}

.accordion-trigger-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.accordion-trigger-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.accordion-trigger-btn svg {
    transition: transform 0.2s ease;
}

.accordion-trigger-btn.expanded svg {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-content.expanded {
    max-height: 800px;
    margin-top: var(--spacing-md);
}

.accordion-inner {
    padding: var(--spacing-md);
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* Danger Zone */
.danger-zone {
    margin-top: var(--spacing-xl);
    padding: var(--spacing-md);
    border: 1.5px dashed var(--danger-color);
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.05);
}

.danger-zone-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--danger-color);
    margin-bottom: var(--spacing-sm);
}

.danger-zone-description {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-md);
}

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

.danger-btn:hover {
    background-color: #dc2626;
    border-color: #dc2626;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--surface-color);
    color: var(--text-main);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    z-index: 10000;
    opacity: 0;
    transform: translateY(1rem);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.toast.toast-show {
    opacity: 1;
    transform: translateY(0);
}

.toast.toast-success {
    border-left: 3px solid var(--success-color);
}

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

.toast-icon {
    flex-shrink: 0;
}

.toast-success .toast-icon {
    color: var(--success-color);
}

.toast-error .toast-icon {
    color: var(--danger-color);
}

.toast-message {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* 2FA Modal specific adjustments */
#setup-2fa-modal .modal-content {
    max-width: 520px;
}

#setup-2fa-modal .modal-header h2 {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}
