:root {
    --primary: #334155;
    --primary-hover: #1e293b;
    --bg: #f8fafc;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --card-bg: #ffffff;
    --danger: #ef4444;
    --accent: #64748b;
    --header-bg: #ffffff;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    display: flex;
    justify-content: center;
    padding: 0;
    min-height: 100vh;
}

#app {
    width: 100%;
    max-width: 1000px;
    background: transparent;
    padding: 2rem;
    align-self: flex-start;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--header-bg);
    padding: 1rem 2rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 2.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

h1 { 
    margin: 0; 
    font-size: 1.25rem; 
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--primary);
    flex-shrink: 0;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: #f1f5f9;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    border: 1px solid var(--border);
    margin-left: auto;
    margin-right: 1rem;
}

#user-info::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
}

nav {
    display: flex;
    gap: 0.75rem;
}

section {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 400px;
    margin: 0 auto;
}

input, textarea, select, button {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(51, 65, 85, 0.1);
}

button {
    background-color: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

button:active {
    transform: translateY(0);
}

button.secondary {
    background-color: #ffffff;
    color: var(--primary);
    border: 1px solid var(--border);
}

button.secondary:hover {
    background-color: #f8fafc;
    border-color: var(--primary);
}

/* Auth Card (Login/Register) */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
}

.auth-card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 400px;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.auth-card input {
    background: #f8fafc;
    border: 1px solid var(--border);
}

.auth-card button {
    width: 100%;
    margin-top: 0.5rem;
}

.auth-card h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.auth-card p {
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-card a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-card a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

/* Toasts */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 9999;
}

.toast {
    background: var(--primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease-out;
    min-width: 250px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

.toast.error {
    background: var(--danger);
}

.toast.success {
    background: #10b981;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.fade-out {
    animation: fadeOut 0.3s ease-in forwards;
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

.actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1.5rem;
}

/* Vault Grid */
#vault-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.vault-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 1.25rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.vault-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-color: var(--primary);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.favicon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary);
    border: 1px solid var(--border);
    font-size: 1.1rem;
}

.favicon img {
    border-radius: 4px;
}

.card-info {
    flex: 1;
    overflow: hidden;
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    position: relative;
}

.close-modal-x {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    transition: color 0.2s;
}

.close-modal-x:hover {
    color: var(--danger);
    background: none;
    transform: none;
    box-shadow: none;
}

.detail-row {
    margin-bottom: 1.25rem;
}

.detail-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.detail-value {
    font-family: inherit;
    background: #f8fafc;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s;
}

.detail-value:hover {
    border-color: var(--primary);
}

.copy-btn {
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.admin-vault-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.admin-vault-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-vault-info strong {
    display: block;
    font-size: 1rem;
}

.admin-vault-info small {
    color: var(--text-muted);
}

.admin-vault-tags {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background: #f1f5f9;
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    border: 1px solid var(--border);
}

.tag button {
    padding: 0;
    background: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    border: none;
    cursor: pointer;
    transition: color 0.2s;
}

.tag button:hover {
    color: var(--danger);
    transform: none;
    box-shadow: none;
}

.role-badge {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.role-badge.admin {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fee2e2;
}

.role-badge.user {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #dcfce7;
}

/* Audit Log Styles */
.log-action-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.log-action-badge.success {
    background: #f1f5f9;
    color: var(--primary);
}

.log-action-badge.failed {
    background: #fee2e2;
    color: var(--danger);
}

.audit-table td {
    vertical-align: middle;
}

/* Mobile Optimierungen */
@media (max-width: 768px) {
    #app {
        padding: 1rem;
    }

    header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
        text-align: center;
    }

    #user-info {
        margin: 0;
        width: fit-content;
    }

    nav {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    nav button {
        flex: 1;
        min-width: 120px;
        font-size: 0.8rem;
        padding: 0.6rem;
    }

    .auth-container {
        min-height: calc(100vh - 250px);
    }

    .auth-card {
        padding: 1.5rem;
    }

    #vault-list {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .modal-content {
        padding: 1.5rem;
        width: 95%;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .admin-vault-grid {
        grid-template-columns: 1fr;
    }

    .admin-card-details {
        grid-template-columns: 1fr;
    }

    .admin-detail-item {
        grid-column: span 1 !important;
    }

    .admin-tabs {
        flex-direction: column;
    }

    /* Tabellen auf Mobile */
    .table-container {
        border: none;
    }

    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        border: 1px solid var(--border);
        border-radius: 8px;
        margin-bottom: 1rem;
        background: white;
        padding: 0.5rem;
    }

    td {
        border: none;
        position: relative;
        padding-left: 50%;
        text-align: right;
    }

    td:before {
        position: absolute;
        top: 50%;
        left: 1rem;
        transform: translateY(-50%);
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 700;
        color: var(--text-muted);
        font-size: 0.75rem;
        text-transform: uppercase;
    }

    #admin-view-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .admin-header-actions {
        width: 100%;
        justify-content: center;
    }

    .admin-header-actions button {
        flex: 1;
    }

    .detail-value {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .copy-btn {
        width: 100%;
    }

    /* Labels für die Admin-Benutzertabelle */
    td:nth-of-type(1):before { content: "Benutzer"; }
    td:nth-of-type(2):before { content: "Email"; }
    td:nth-of-type(3):before { content: "Rolle"; }
    td:nth-of-type(4):before { content: "Registriert"; }

    /* Zentrierung auf Mobile aufheben, da Cards */
    td.text-center {
        text-align: right !important;
    }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    will-change: opacity, transform;
}

section {
    animation: fadeIn 0.3s ease-out;
}

.vault-card {
    animation: slideUp 0.4s ease-out backwards;
}

#vault-list > .vault-card:nth-child(1) { animation-delay: 0.05s; }
#vault-list > .vault-card:nth-child(2) { animation-delay: 0.1s; }
#vault-list > .vault-card:nth-child(3) { animation-delay: 0.15s; }
#vault-list > .vault-card:nth-child(4) { animation-delay: 0.2s; }
#vault-list > .vault-card:nth-child(5) { animation-delay: 0.25s; }

.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: #f1f5f9;
    padding: 0.4rem;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.admin-tabs button {
    flex: 1;
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 0.6rem;
    border-radius: 8px;
    font-weight: 600;
}

.admin-tabs button.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Modern Admin Tables */
.table-container {
    overflow-x: auto;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #f8fafc;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    text-align: left;
    vertical-align: middle;
}

.text-center {
    text-align: center !important;
}

th.text-center {
    text-align: center !important;
}

tr:last-child td { border-bottom: none; }

.role-badge {
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}

.role-badge.admin { background: #fee2e2; color: #991b1b; }
.role-badge.user { background: #dcfce7; color: #166534; }

/* Admin Vault Cards */
.admin-vault-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.25rem;
}

.admin-vault-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.admin-vault-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.admin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.admin-card-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.admin-card-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    background: #f8fafc;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
}

.admin-detail-item b {
    display: block;
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.15rem;
}

.admin-share-section {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.admin-vault-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* User Selection Grid (Admin Entry Creation) */
.user-selection-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    max-height: 200px;
    overflow-y: auto;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
}

.selectable-user-badge {
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    background: white;
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.selectable-user-badge:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.selectable-user-badge.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
