:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --primary: #6366f1;
    /* Indigo */
    --primary-hover: #4f46e5;
    --accent: #8b5cf6;
    /* Violet */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --danger: #ef4444;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 500px;
    background: var(--bg-color);
    /* Matches body for seamless mobile feel */
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Views Logic */
.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, opacity 0.3s ease;
    padding: 20px;
}

.view.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(50px);
}

.view.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.hidden {
    display: none !important;
}

/* Landing Page */
#landing-view {
    justify-content: center;
    text-align: center;
}

/* Hero Section */
.hero {
    margin-bottom: 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    line-height: 1.1;
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    color: var(--text-muted);
    margin-bottom: 3rem;
    font-size: 1.1rem;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    font-size: 1.1rem;
    padding: 16px 32px;
    border-radius: 12px;
    width: 100%;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    transform: scale(0.98);
}

.join-list {
    margin-top: 2rem;
    display: flex;
    gap: 10px;
}

#join-code-input {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: white;
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    text-transform: uppercase;
    font-size: 1rem;
}

.btn-secondary {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
}

/* Auth Forms */
.auth-form {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form h3 {
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.auth-form input {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: white;
    padding: 12px;
    border-radius: 10px;
    font-size: 1rem;
}

.form-switch {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.form-switch a {
    color: var(--primary);
    text-decoration: none;
}

.form-switch a:hover {
    text-decoration: underline;
}

/* Dashboard */
.dashboard-content {
    padding-top: 1rem;
}

.join-section {
    display: flex;
    gap: 10px;
    margin: 1.5rem 0;
}

.join-section input {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: white;
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    text-transform: uppercase;
}

.dashboard-content h3 {
    margin: 2rem 0 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.list-cards {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-card {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-card:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.list-card-info h4 {
    margin: 0 0 0.25rem 0;
    color: var(--text-main);
}

.list-card-info p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.list-card-badge {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
}

/* List View */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 50%;
}

.btn-icon:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.navbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .2s;
    overflow: hidden;
}

.navbar-avatar:hover {
    transform: scale(1.05);
}

.nav-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
}

.nav-menu-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.avatar-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-weight: bold;
}

.header-title {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.header-title h2 {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon-small {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 4px;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.btn-icon-small:hover {
    opacity: 1;
    color: var(--primary);
}

.code-badge {
    font-size: 0.75rem;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 1px;
}

.modal-content input[type="text"] {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: white;
    padding: 12px;
    border-radius: 10px;
    font-size: 1rem;
    width: 100%;
    margin-bottom: 1rem;
}

/* Input Area */
.input-area {
    margin-bottom: 1.5rem;
    position: relative;
    /* For absolute positioning of suggestions */
}

#add-item-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--card-bg);
    padding: 8px;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    z-index: 20;
    /* Above suggestions */
    position: relative;
}

/* Fallback for cached client-side HTML (prevents vertical layout disaster) */
#add-item-form:not(:has(.add-item-row)) {
    flex-direction: row;
    align-items: center;
}

.add-item-row {
    display: flex;
    gap: 10px;
    width: 100%;
    align-items: center;
}

.add-item-comment-row {
    width: 100%;
    border-top: 1px solid var(--border);
    padding-top: 4px;
}

#new-item-comment {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 12px;
    font-size: 0.85rem;
    outline: none;
}

#new-item-comment:focus {
    color: var(--text-main);
}

.unit-select {
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    color: var(--primary);
    font-weight: 600;
    padding: 0 8px 0 0;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
    text-align: center;
}

.unit-select option {
    background: var(--card-bg);
    color: var(--text-main);
}

#new-item-input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    padding: 8px 12px;
    font-size: 1rem;
    outline: none;
}

.btn-add {
    background: var(--primary);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Suggestions Dropdown */
.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 10px;
    right: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 12px 12px;
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: var(--shadow-lg);
    margin-top: -5px;
    /* Pull up to connect with input */
    padding-top: 10px;
}

.suggestions-dropdown.hidden {
    display: none;
}

.suggestions-dropdown li {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-muted);
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
}

.suggestions-dropdown li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.suggestions-dropdown li:last-child {
    border-bottom: none;
}

.suggestion-highlight {
    color: var(--success);
    font-weight: 600;
}

/* Items List */
.items-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 80px;
    /* Space for scrolling */
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.items-container::-webkit-scrollbar {
    display: none;
}

/* Items Grid */
.item-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    /* Always 4 columns */
    gap: 6px;
    padding: 2px;
    list-style: none;
}

/* Base item style for smaller tiles */
.item {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 12px;
    /* Smaller radius */
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 6px;
    /* Less padding */
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    border: 2px solid transparent;
    user-select: none;
}

.item:active {
    transform: scale(0.95);
}

.item.checked {
    opacity: 0.4;
    filter: grayscale(80%);
    box-shadow: none;
}

/* Tile Content */
.tile-content {
    z-index: 2;
    width: 100%;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.item-name-tile {
    display: block;
    font-size: 0.9rem;
    /* Increased from 0.75rem */
    font-weight: 600;
    line-height: 1.1;
    margin-bottom: 2px;
    word-break: break-word;
    /* Ensure wrapping */
    hyphens: auto;
    /* Hyphenate if needed */
}

.qty-badge-tile {
    background: var(--primary);
    color: white;
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
    display: inline-block;
    margin-bottom: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.added-by {
    font-size: 0.65rem;
    opacity: 0.9;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #e2e8f0;
}

.item-comment-tile {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-top: 3px;
    color: #e2e8f0;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tile-category-icon {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 1.2rem;
    opacity: 0.9;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}

/* Actions (Delete) */
.tile-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    display: flex;
    gap: 4px;
}

.btn-delete-tile,
.btn-learn-tile {
    background: rgba(0, 0, 0, 0.4);
    color: rgba(255, 255, 255, 0.9);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    border: none;
    cursor: pointer;
}

/* Learn button explicitly top left (via HTML position) */
.btn-learn-tile {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    background: rgba(255, 255, 255, 0.2);
}

.btn-delete-tile:hover {
    background: var(--danger);
    color: white;
    transform: scale(1.1);
}

.btn-learn-tile:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

/* Checked Overlay */
.checked-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    font-size: 3rem;
    color: var(--success);
    z-index: 3;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Hide old list elements if any remain */
.checkbox,
.btn-delete,
.item-icon,
.qty-badge {
    display: none;
}

.divider {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin: 20px 0 10px;
    padding-left: 10px;
}



.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-style: italic;
    font-size: 1.1rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    color: var(--text-main);
    padding: 1rem 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    transition: opacity 0.3s;
}

.toast.hidden {
    display: none;
}

/* Learn Button */
.btn-learn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 1.1rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-learn:hover {
    opacity: 1;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.modal-content p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 1.5rem;
}

.category-option {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.category-option:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.category-option i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

.category-option span {
    font-size: 0.85rem;
    display: block;
}

/* Quantity Selection */
.quantity-select {
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    color: var(--primary);
    font-weight: 600;
    padding: 0 8px;
    /* reduced padding */
    font-size: 1rem;
    outline: none;
    cursor: pointer;
    text-align: center;
}

/* Fix option color in dark mode */
.quantity-select option {
    background: var(--card-bg);
    color: var(--text-main);
}

.qty-badge {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9em;
    background: rgba(139, 92, 246, 0.15);
    /* light accent bg */
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 6px;
}

/* List Card Actions */
.list-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-icon-delete-list {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-icon-delete-list:hover {
    background: var(--danger);
    color: white;
    transform: scale(1.05);
}

.btn-icon-leave-list {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-icon-leave-list:hover {
    background: #f59e0b;
    color: white;
    transform: scale(1.05);
}

/* Ensure checked items look interactive */
.item.checked {
    cursor: pointer;
}

/* Checked items list: Row layout instead of grid */
.checked-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

.checked-list .item {
    aspect-ratio: unset !important;
    height: auto !important;
    min-height: 50px;
    padding: 12px 80px 12px 16px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg) !important;
    background-image: none !important;
    opacity: 1 !important;
    transition: none !important;
    animation: none !important;
}

.checked-list .item::before {
    display: none;
}

.checked-list .tile-content {
    display: flex;
    align-items: center;
    gap: 12px;
    text-shadow: none;
    color: #ffffff !important;
}

.checked-list .item-name-tile {
    font-size: 0.9rem;
    text-decoration: line-through;
    color: #ffffff !important;
}

.checked-list .qty-badge-tile {
    background: var(--border);
    font-size: 0.75rem;
    color: #ffffff !important;
}

.checked-list .btn-learn {
    display: none;
}

.checked-list .tile-actions {
    top: 50% !important;
    transform: translateY(-50%) !important;
    right: 12px !important;
}

/* Favorite Star on Active Cards (Top-Left) */
.btn-favorite-card {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 5;
    background: rgba(15, 23, 42, 0.6);
    color: rgba(255, 255, 255, 0.4);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.btn-favorite-card:hover {
    color: #fbbf24;
    transform: scale(1.1);
    background: rgba(15, 23, 42, 0.8);
}

.btn-favorite-card.active {
    color: #fbbf24;
    opacity: 1;
    filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.8));
    background: rgba(15, 23, 42, 0.7);
}

/* Favorite Star on Checked Rows (Next to Trash Can) */
.btn-favorite-tile {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.4);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-favorite-tile:hover {
    color: #fbbf24;
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.1);
}

.btn-favorite-tile.active {
    color: #fbbf24;
    filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.8));
}

/* ==================== ADMIN PANEL STYLE ==================== */

#admin-view {
    padding: 10px;
}

.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.admin-tabs::-webkit-scrollbar {
    display: none;
}

.admin-tabs .tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-tabs .tab-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.admin-tabs .tab-btn.active {
    color: #ffffff;
    background: var(--primary);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.admin-content-area {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 15px;
    flex: 1;
    overflow-y: auto;
}

.admin-content-area h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2rem;
    font-weight: 600;
}

.admin-info-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    line-height: 1.4;
}

.admin-table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
}

.admin-table th, 
.admin-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.admin-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.role-badge.admin {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.role-badge.user {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: #ef4444;
    color: #ffffff;
}

.btn-admin-edit {
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.table-inline-form {
    display: flex;
    gap: 8px;
}

.admin-select-category {
    padding: 6px;
    border-radius: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.85rem;
    flex-grow: 1;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.admin-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-form label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.admin-form input,
.admin-form textarea {
    padding: 12px;
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.admin-form input:focus,
.admin-form textarea:focus {
    border-color: var(--primary);
}

.admin-form textarea {
    min-height: 100px;
    resize: vertical;
}

.badge-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* ==================== RESPONSIVE DESIGN (DESKTOP / WIDESCREEN) ==================== */

@media (min-width: 768px) {
    /* Expand app container for tablet and desktop */
    .app-container {
        max-width: 1280px;
        border-radius: 20px;
        margin: 20px auto;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
        border: 1px solid var(--border);
        height: calc(100vh - 40px);
        min-height: 600px;
    }

    /* Centered Auth Forms */
    .auth-form {
        max-width: 400px;
        margin-left: auto;
        margin-right: auto;
        width: 100%;
    }
    
    .hero {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    /* Dashboard: Grid of lists instead of single column */
    .list-cards {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 16px;
    }

    /* Shopping List: Grid of item cards instead of 4 strict columns */
    .item-list {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
        gap: 12px !important;
    }

    /* Checked items list: Grid layout or cleaner rows on desktop */
    .checked-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 12px;
    }

    /* Admin Panel: Side-by-side or spacious layout */
    .admin-content-area {
        padding: 20px;
    }
}

/* App Switcher Dropdown */
.app-switcher {
    position: absolute;
    top: 60px;
    right: 20px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 0;
    width: 200px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.app-switcher.hidden {
    display: none !important;
}

.app-switcher a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.2s;
}

.app-switcher a:hover {
    background: rgba(255, 255, 255, 0.05);
}

.app-switcher a i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

#switcher-portal-link i {
    color: var(--primary);
}

#switcher-fit-link i {
    color: #ec4899; /* Pink color for fitness app */
}

/* Share modal group card styling */
.group-share-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.9rem;
    gap: 10px;
}

.group-share-card span {
    font-weight: 600;
    color: var(--text-main);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-share-card button {
    background: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.group-share-card button:hover {
    background: var(--primary-hover);
}

.group-share-card button:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* ==================== SIDE DRAWER ==================== */

.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    transition: opacity .25s;
}
.drawer-overlay.open {
    display: block;
}

.drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 501;
    width: 280px;
    background: #1a2235;
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.drawer.open {
    transform: translateX(0);
}

/* Zone 1 — Kopf */
.drawer-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 20px 18px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    flex-shrink: 0;
}
.drawer-logo {
    font-size: 32px;
    line-height: 1;
    flex-shrink: 0;
}
.drawer-user-info {
    flex: 1;
    min-width: 0;
}
.drawer-app-name {
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.drawer-email {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 3px;
    word-break: break-all;
    color: rgba(255, 255, 255, 0.9);
}

/* Zone 2 — Mitte (App-spezifisch) */
.drawer-zone-mid {
    flex: 1;
}
.drawer-nav {
    padding: 10px 12px;
}

.drawer-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: background .15s, color .15s;
    margin-bottom: 2px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.drawer-item:hover,
.drawer-item--active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
}
.drawer-item--danger {
    color: var(--danger) !important;
}
.drawer-item--danger:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: var(--danger) !important;
}
.drawer-icon {
    font-size: 18px;
    flex-shrink: 0;
}

/* Trennlinie */
.drawer-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 20px;
}

/* Zone 3 — Fuß (feste globale Links) */
.drawer-footer {
    margin-top: auto;
    padding-bottom: 8px;
}

.btn-drawer-trigger {
    color: var(--text-muted);
}
.btn-drawer-trigger:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* ── Avatar Lightbox Overlay ── */
.av-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
}
.av-overlay.open {
    display: flex;
    animation: avFadeIn .2s ease;
}
@keyframes avFadeIn { from { opacity: 0; } to { opacity: 1; } }
.av-overlay__img {
    max-width: min(90vw, 480px);
    max-height: 80vh;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .15), 0 24px 60px rgba(0, 0, 0, .6);
    animation: avZoomIn .25s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes avZoomIn {
    from { transform: scale(.7); opacity: 0; }
    to   { transform: scale(1);  opacity: 1; }
}
.av-overlay__close {
    position: absolute;
    top: 20px; right: 20px;
    background: rgba(255, 255, 255, .15);
    border: none; color: #fff;
    font-size: 22px; width: 44px; height: 44px;
    border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}
.av-overlay__close:hover { background: rgba(255, 255, 255, .3); }