/* iOS Dark Mode Variables */
:root {
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --bg-elevated: #3a3a3c;
    --text-primary: #ffffff;
    --text-secondary: #ebebf5;
    --text-tertiary: #8e8e93;
    --accent-blue: #0a84ff;
    --accent-green: #30d158;
    --accent-red: #ff453a;
    --separator: rgba(84, 84, 88, 0.6);
    --shadow: rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom);
}

.app-container {
    max-width: 100%;
    min-height: 100vh;
    padding-bottom: 40px;
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: env(safe-area-inset-top) 20px 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 0.5px solid var(--separator);
    z-index: 100;
}

.app-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.settings-btn {
    background: none;
    border: none;
    color: var(--accent-blue);
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.settings-btn:active {
    opacity: 0.5;
}

/* Meal Plan Section */
.meal-plan-section {
    padding: 24px 20px;
    border-bottom: 8px solid var(--bg-primary);
}

.meal-plan-section h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.meal-plan-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.meal-day-card {
    background-color: var(--bg-secondary);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
    min-height: 60px;
}

.meal-day-card:active {
    background-color: var(--bg-tertiary);
}

.meal-day-info {
    flex: 1;
}

.meal-day-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.meal-name {
    font-size: 15px;
    color: var(--text-secondary);
}

.meal-name.empty {
    color: var(--text-tertiary);
    font-style: italic;
}

.chevron {
    color: var(--text-tertiary);
    opacity: 0.6;
}

/* Shopping List Section */
.shopping-list-section {
    padding: 24px 20px;
}

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

.section-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Add Item */
.add-item-container {
    position: relative;
    margin-bottom: 20px;
}

.add-item-container input {
    width: 100%;
    background-color: var(--bg-secondary);
    border: none;
    border-radius: 10px;
    padding: 14px 50px 14px 16px;
    font-size: 17px;
    color: var(--text-primary);
    outline: none;
}

.add-item-container input::placeholder {
    color: var(--text-tertiary);
}

.add-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--accent-blue);
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.add-btn:active {
    opacity: 0.5;
}

/* Autocomplete */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-elevated);
    border-radius: 10px;
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 4px 16px var(--shadow);
    z-index: 10;
}

.autocomplete-dropdown.show {
    display: block;
}

.autocomplete-item {
    padding: 14px 16px;
    font-size: 17px;
    color: var(--text-primary);
    cursor: pointer;
    border-bottom: 0.5px solid var(--separator);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:active {
    background-color: var(--bg-tertiary);
}

/* Shopping List */
.shopping-list {
    list-style: none;
}

.shopping-item {
    background-color: var(--bg-secondary);
    border-radius: 10px;
    margin-bottom: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: grab;
    transition: background-color 0.2s;
}

.shopping-item:active {
    cursor: grabbing;
}

.shopping-item.sortable-ghost {
    opacity: 0.4;
}

.shopping-item.sortable-drag {
    background-color: var(--bg-elevated);
    box-shadow: 0 4px 16px var(--shadow);
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 24px;
}

.custom-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--text-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

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

.custom-checkbox svg {
    display: none;
    width: 14px;
    height: 14px;
    stroke: white;
    stroke-width: 3;
}

.custom-checkbox.checked svg {
    display: block;
}

.item-name {
    flex: 1;
    font-size: 17px;
    color: var(--text-primary);
    transition: all 0.2s;
}

.item-name.checked {
    color: var(--text-tertiary);
    text-decoration: line-through;
}

.drag-handle {
    color: var(--text-secondary);
    opacity: 0.7;
    cursor: grab;
    padding: 4px;
    min-width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn {
    background: none;
    border: none;
    color: var(--accent-red);
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.shopping-item:hover .delete-btn {
    opacity: 1;
}

.delete-btn:active {
    opacity: 0.5;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: flex-end;
    z-index: 1000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: var(--bg-secondary);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    padding-bottom: env(safe-area-inset-bottom);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    position: sticky;
    top: 0;
    background-color: var(--bg-secondary);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 0.5px solid var(--separator);
    z-index: 10;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: var(--accent-blue);
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.close-btn:active {
    opacity: 0.5;
}

/* Add Meal Container */
.add-meal-container {
    position: relative;
    padding: 20px;
    border-bottom: 0.5px solid var(--separator);
}

.add-meal-container input {
    width: 100%;
    background-color: var(--bg-tertiary);
    border: none;
    border-radius: 10px;
    padding: 14px 50px 14px 16px;
    font-size: 17px;
    color: var(--text-primary);
    outline: none;
}

.add-meal-container input::placeholder {
    color: var(--text-tertiary);
}

.add-meal-container .add-btn {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
}

/* Meals List */
.meals-list,
.meals-select-list {
    list-style: none;
    padding: 20px 20px 20px 20px;
}

.meal-item {
    background-color: var(--bg-tertiary);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.meal-item:active {
    background-color: var(--bg-elevated);
}

.meal-item-name {
    font-size: 17px;
    color: var(--text-primary);
    flex: 1;
}

.meal-item-actions {
    display: flex;
    gap: 8px;
}

.edit-btn,
.meal-delete-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.edit-btn {
    color: var(--accent-blue);
}

.meal-delete-btn {
    color: var(--accent-red);
}

.edit-btn:active,
.meal-delete-btn:active {
    opacity: 0.5;
}

/* Meal Select List */
.meal-select-item {
    background-color: var(--bg-tertiary);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 8px;
    font-size: 17px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.2s;
}

.meal-select-item:active {
    background-color: var(--bg-elevated);
}

.meal-select-item.clear {
    color: var(--accent-red);
    text-align: center;
}

/* Scrollbar styling for webkit browsers */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
    font-size: 17px;
}
