:root {
    --primary: #3b82f6;
    /* Premium Blue */
    --primary-dark: #1d4ed8;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    /* Slate Dark */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(148, 163, 184, 0.1);
    --text-white: #f1f5f9;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background: var(--bg-gradient);
    min-height: 100vh;
    color: var(--text-white);
    overflow-x: hidden;
    font-size: 16px;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.glass-input,
.glass-select {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text-white);
    padding: 12px;
    border-radius: 8px;
    width: 100%;
    outline: none;
    transition: 0.3s;
    font-size: 0.95rem;
}

.glass-input:focus {
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.8);
}

.glass-btn {
    background: rgba(51, 65, 85, 0.5);
    border: 1px solid var(--glass-border);
    color: var(--text-white);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: 0.2s;
    font-size: 0.95rem;
}

.glass-btn:hover {
    background: rgba(51, 65, 85, 0.8);
}

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

.glass-btn.primary:hover {
    background: var(--primary-dark);
}

.glass-btn.danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.glass-btn.danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.glass-btn.sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Layout */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 40px);
    /* Footer space */
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 0;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-white);
    text-decoration: none;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 50px;
    transition: 0.2s;
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.1);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.9rem;
}

/* Auth Screens */
.auth-box {
    text-align: center;
    padding: 40px 25px;
    margin-top: 40px;
}

.auth-tabs {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--glass-border);
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding-bottom: 10px;
    font-weight: 500;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

/* List View */
.input-group {
    display: flex;
    gap: 10px;
    position: relative;
    margin-bottom: 20px;
}

.product-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-radius: 0 0 8px 8px;
    z-index: 50;
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.suggestion-item {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.suggestion-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.suggestion-name {
    flex: 1;
    cursor: pointer;
    transition: color 0.2s;
}

.suggestion-name:hover {
    color: var(--primary);
}

.suggestion-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.suggestion-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s, transform 0.2s;
    opacity: 0.6;
}

.suggestion-delete-btn:hover {
    color: var(--danger);
    opacity: 1;
    transform: scale(1.2);
}

/* Category Switch Buttons */
.cat-btn {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.cat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
}

.cat-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 600;
}

.shopping-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    transition: all 0.2s;
}

.list-item.checked {
    opacity: 0.5;
}

.list-item.checked .item-name {
    text-decoration: line-through;
}

.item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    cursor: pointer;
}

.item-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    line-height: 1;
}

.remove-btn:hover {
    color: var(--danger);
}

.category-tag {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.tag-frais {
    color: #34d399;
}

.tag-surg {
    color: #60a5fa;
}

.tag-sec {
    color: #fbbf24;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.2s;
}

.checked .checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}

.checked .checkbox-custom::after {
    content: '✓';
    font-size: 14px;
    color: white;
}

/* History & Admin Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    text-align: left;
    padding: 10px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--glass-border);
}

.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.status-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
}

.status-pro {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.status-free {
    background: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
}

.status-admin {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    margin-left: 5px;
    transition: 0.2s;
}

.icon-btn:hover {
    transform: scale(1.1);
}

.status-pro {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.status-free {
    background: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    /* Darker overlay */
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: #1e293b;
    padding: 30px;
    width: 100%;
    max-width: 450px;
    border-radius: 16px;
    position: relative;
    border: 1px solid var(--glass-border);
    max-height: 90vh;
    overflow-y: auto;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-muted);
}

.close-modal:hover {
    color: white;
}

.storage-bar-container {
    background: rgba(255, 255, 255, 0.05);
    height: 8px;
    border-radius: 4px;
    margin-top: 15px;
    overflow: hidden;
}

.storage-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: 0.5s ease-out;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(16, 185, 129, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 500;
    z-index: 2000;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

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

/* Category Headers in List */
.category-header {
    padding: 6px 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 12px;
    margin-bottom: 4px;
    list-style: none;
}

.category-header:first-child {
    margin-top: 0;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: auto;
}