/**
 * QRVault - Haupt-Stylesheet (Dark Mode Only)
 * Schlichtes, modernes Smart-Home-Interface für Mobile & Desktop.
 */

@import url('variables.css');

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    color-scheme: dark;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--accent-primary-hover);
}

/* ============================================================================
   Top Navigation Bar & Mobile Burger Drawer
   ============================================================================ */
.app-navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(19, 26, 39, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 20px;
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.navbar-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.navbar-mobile-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.burger-toggle-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.burger-toggle-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.18rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.brand-link:hover {
    color: var(--text-primary);
}

.brand-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.2), rgba(20, 184, 166, 0.15));
    border: 1px solid rgba(0, 210, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    box-shadow: 0 0 16px var(--accent-glow);
    flex-shrink: 0;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 4px;
    padding: 2px 8px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-divider {
    width: 1px;
    height: 24px;
    background: var(--border-subtle);
    margin: 0 4px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 13px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.92rem;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-surface-elevated);
}

.nav-link.active {
    color: var(--accent-primary);
    background: var(--accent-glow);
    border-color: rgba(0, 210, 255, 0.28);
}

.nav-logout-link {
    color: var(--text-muted);
}

.nav-logout-label {
    display: none;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.15s ease;
    white-space: nowrap;
}

.user-chip:hover {
    border-color: var(--accent-primary);
}

.role-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    font-weight: 700;
}

.role-badge.admin {
    background: rgba(0, 210, 255, 0.16);
    color: var(--accent-primary);
}

.role-badge.user {
    background: rgba(148, 163, 184, 0.16);
    color: var(--text-secondary);
}

/* ============================================================================
   Main Container & Layout
   ============================================================================ */
.app-container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 24px 20px 64px;
}

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

.page-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-description {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

/* ============================================================================
   Cards & Surfaces
   ============================================================================ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-card);
}

/* ============================================================================
   Buttons
   ============================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.2;
}

.btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: #364869;
}

.btn-primary {
    background: var(--accent-primary);
    color: #06101a;
    border-color: var(--accent-primary);
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
    border-color: var(--accent-primary-hover);
    color: #06101a;
    box-shadow: 0 0 18px var(--accent-glow);
}

.btn-danger {
    background: var(--danger-bg);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #fecaca;
}

.btn-sm {
    padding: 6px 11px;
    font-size: 0.83rem;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
}

/* ============================================================================
   Forms & Inputs (Dark Mode)
   ============================================================================ */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 13px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-hint {
    display: block;
    margin-top: 5px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ============================================================================
   Login Screen
   ============================================================================ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at 50% 0%, rgba(0, 210, 255, 0.08), transparent 55%), var(--bg-app);
}

.auth-card {
    width: 100%;
    max-width: 410px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    box-shadow: var(--shadow-modal);
}

.auth-header {
    text-align: center;
    margin-bottom: 26px;
}

.auth-logo {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    margin: 0 auto 14px;
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.22), rgba(20, 184, 166, 0.15));
    border: 1px solid rgba(0, 210, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    box-shadow: 0 0 24px var(--accent-glow);
}

.auth-title {
    margin: 0 0 6px;
    font-size: 1.45rem;
    font-weight: 700;
}

.auth-subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================================================
   Alerts & Toasts
   ============================================================================ */
.alert {
    padding: 12px 15px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-danger {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #6ee7b7;
}

.toast-container {
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--accent-primary);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-modal);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    min-width: 260px;
    max-width: 380px;
    animation: slideInUp 0.2s ease-out;
}

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

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

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

/* ============================================================================
   Tables (Dark Mode)
   ============================================================================ */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.vault-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.vault-table th {
    padding: 12px 14px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(14, 20, 32, 0.5);
}

.vault-table td {
    padding: 14px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    font-size: 0.92rem;
}

.vault-table tr:last-child td {
    border-bottom: none;
}

.vault-table tbody tr:hover {
    background: rgba(33, 44, 64, 0.35);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 600;
}

.status-pill.active {
    background: var(--success-bg);
    color: #34d399;
}

.status-pill.disabled {
    background: var(--danger-bg);
    color: #f87171;
}

/* ============================================================================
   Modals
   ============================================================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 14, 0.78);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
}

.modal-backdrop.open {
    display: flex;
}

.modal-dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-modal);
    overflow: hidden;
    max-height: 90vh;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
}

.modal-dialog > form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-title {
    margin: 0;
    font-size: 1.12rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 9px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
}

.modal-body {
    padding: 22px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border-subtle);
    background: rgba(14, 20, 32, 0.45);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

/* ============================================================================
   Responsive Mobile Adjustments & Burger Drawer
   ============================================================================ */
@media (max-width: 960px) {
    .app-navbar {
        flex-direction: column;
        align-items: stretch;
        padding: 0 14px;
        height: auto;
    }

    .navbar-top-row {
        width: 100%;
        height: 60px;
    }

    .brand-subtitle {
        display: none;
    }

    .burger-toggle-btn {
        display: inline-flex;
    }

    .nav-actions {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 12px 0 16px;
        border-top: 1px solid var(--border-subtle);
        width: 100%;
    }

    .nav-actions.open {
        display: flex;
    }

    .nav-link,
    .nav-install-btn {
        width: 100%;
        justify-content: flex-start;
        padding: 11px 14px;
        font-size: 0.96rem;
    }

    .nav-divider {
        width: 100%;
        height: 1px;
        margin: 6px 0;
    }

    .user-chip {
        width: 100%;
        justify-content: space-between;
        padding: 10px 14px;
        border-radius: var(--radius-sm);
    }

    .nav-logout-label {
        display: inline;
    }

    .nav-logout-link {
        color: #fca5a5;
    }
}

@media (max-width: 680px) {
    .app-container {
        padding: 16px 12px 84px;
    }
    .search-row .btn-primary span.nav-label {
        display: none;
    }
}
