/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables */
:root {
    --primary: #f97316;
    --primary-hover: #ea580c;
    --primary-light: #fff7ed;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --bg: #ffffff;
    --bg-secondary: #f9fafb;
    --border: #e5e7eb;
    --text: #111827;
    --text-secondary: #6b7280;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* Dark Mode Theme */
body.dark-mode {
    --primary: #fb923c;
    --primary-hover: #ea7c1f;
    --primary-light: #9a3412;
    --danger: #f87171;
    --danger-hover: #ef4444;
    --bg: #1a1a1a;
    --bg-secondary: #242424;
    --border: #3a3a3a;
    --text: #e5e5e5;
    --text-secondary: #a3a3a3;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.5);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.6);
    background: var(--bg);
}

body.dark-mode .user-menu-toggle .avatar {
    box-shadow: 0 0 0 2px var(--bg-secondary);
}

body.dark-mode .user-menu-toggle .chevron {
    color: var(--text);
}

body.dark-mode .user-menu-toggle .chevron svg {
    stroke: var(--text);
}

body.dark-mode .theme-toggle .sun-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

body.dark-mode .theme-toggle .moon-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.8);
}

/* Base Layout */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg-secondary);
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

main {
    background: var(--bg);
    border-radius: 0.5rem;
    padding: 2rem;
    box-shadow: var(--shadow);
}

/* Header */
header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

header .container {
    max-width: none;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    margin: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

header h1 .logo-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

header h1 .logo-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: all 0.3s ease;
    position: absolute;
}

.theme-toggle .sun-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.8);
}

.theme-toggle .moon-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.875rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text);
    transition: background 0.15s ease;
}

.user-menu-toggle:hover {
    background: var(--bg-secondary);
}

.user-menu.active .user-menu-toggle {
    background: var(--bg-secondary);
}

.user-menu-toggle .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: -0.025em;
    flex-shrink: 0;
}

.user-menu-toggle .avatar-icon svg {
    width: 18px;
    height: 18px;
    stroke: white;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.user-menu-toggle .username {
    font-weight: 500;
    color: var(--text);
}

.user-menu-toggle .chevron {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.user-menu.active .user-menu-toggle .chevron {
    transform: rotate(180deg);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.06);
    min-width: 220px;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.user-menu.active .user-menu-dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.user-menu-dropdown .menu-section {
    padding: 0.5rem;
}

.user-menu-dropdown .menu-section:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.user-menu-dropdown .menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    color: var(--text);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: background 0.15s ease;
    cursor: pointer;
    font-size: 0.875rem;
}

.user-menu-dropdown .menu-item:hover {
    background: var(--bg-secondary);
}

.user-menu-dropdown .menu-item .label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-menu-dropdown .menu-item .icon {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.menu-item.danger {
    color: var(--danger);
}

.menu-item.danger:hover {
    background: rgba(220, 38, 38, 0.08);
}

.menu-item.danger .icon {
    color: var(--danger);
}

/* Typography */
h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text);
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

p {
    margin-bottom: 1rem;
}

strong {
    font-weight: 600;
    color: var(--text);
}

/* Links */
a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Buttons */
button,
input[type="submit"],
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

button:hover,
input[type="submit"]:hover,
.btn:hover {
    text-decoration: none;
}

input[type="submit"],
.btn-primary {
    background: var(--primary);
    color: white;
}

input[type="submit"]:hover,
.btn-primary:hover {
    background: var(--primary-hover);
    color: white;
}

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

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

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
}

.btn.with-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn .icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-lg .icon {
    width: 20px;
    height: 20px;
}

.btn .icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Forms */
form {
    margin: 1.5rem 0;
}

.form-container {
    max-width: 500px;
    margin: 0 auto;
}

.form-container h1 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.form-container .form-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.form-actions .btn {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    background: var(--bg);
    color: var(--text);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

/* Checkbox styling */
input[type="checkbox"] {
    accent-color: var(--primary);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

thead th {
    background: var(--bg-secondary);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

tbody tr:hover {
    background: var(--bg-secondary);
}

td {
    padding: 0.875rem 1rem;
}

/* Shopping List Items */
.item-list {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
}

.item {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    background: var(--bg);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.item-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    width: 100%;
}

.item-checkbox input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    flex-shrink: 0;
}

.item-checkbox input[type="checkbox"]:checked + .item-name {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.item-name {
    flex: 1;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-delete-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    transition: color 0.2s;
    flex-shrink: 0;
}

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

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
}

.list-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

/* Cards */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 0;
}

/* Quick add form */
.quick-add-form {
    margin-bottom: 2rem;
}

.quick-add-form form {
    display: flex;
    gap: 0.75rem;
    margin: 0;
}

.quick-add-form input[type="text"] {
    flex: 1;
    margin-bottom: 0;
}

.quick-add-form input[type="submit"] {
    white-space: nowrap;
}

/* Page header */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    margin-bottom: 0.25rem;
}

/* Action button groups */
.action-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.action-group-left {
    flex: 1;
    display: flex;
    gap: 0.75rem;
}

.action-group-right {
    display: flex;
    gap: 0.75rem;
}

/* Actions */
.actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Hero actions (for landing page) */
.hero-actions {
    display: flex;
    justify-content: center;
    margin-top: 3rem;
}

/* Vertically center content */
.hero-content {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.hero-illustration {
    width: 200px;
    height: 200px;
    margin-bottom: 2rem;
}

.hero-illustration svg {
    width: 100%;
    height: 100%;
}

/* List Content */
.list-content {
    margin: 1.5rem 0;
}

/* List cards */
.list-cards {
    display: grid;
    gap: 1rem;
    margin: 1.5rem 0;
}

.list-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    text-decoration: none;
    color: var(--text);
}

.list-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    text-decoration: none;
}

.list-card-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.list-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.list-card-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--primary);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.list-card-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
}

.list-card-arrow {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.list-card:hover .list-card-arrow {
    transform: translateX(4px);
    color: var(--primary);
}

.list-card-arrow svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* SVG Icons */
.icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.with-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.icon {
    font-size: 1.5rem;
    line-height: 1;
}

/* Utilities */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.25rem;
    }

    .user-menu-toggle .username {
        display: none;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    main {
        padding: 1rem;
    }

    .actions {
        flex-direction: column;
    }

    .actions > * {
        width: 100%;
        text-align: center;
    }
}
