* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: visible;
    position: relative;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 20px;
    text-align: center;
    position: relative;
    overflow: visible;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin: 0;
    padding-right: 60px;
    position: relative;
    z-index: 1;
}

.app-version {
    position: absolute;
    bottom: 6px;
    left: 10px;
    font-size: 0.65rem;
    opacity: 0.5;
    color: white;
    pointer-events: none;
}

.menu-button {
    position: absolute !important;
    top: 50% !important;
    right: 15px !important;
    transform: translateY(-50%) !important;
    background: white !important;
    border: 2px solid white !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    padding: 7px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-around !important;
    align-items: center !important;
    width: 36px !important;
    height: 36px !important;
    z-index: 9999 !important;
    transition: all 0.3s ease;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3) !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.menu-button:hover {
    background: #f0f0f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.menu-button span {
    display: block !important;
    width: 20px !important;
    height: 3px !important;
    background: #667eea !important;
    border-radius: 2px !important;
    transition: all 0.3s ease;
    transform-origin: center;
    margin: 1px 0 !important;
}

.menu-button.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.menu-button.active span:nth-child(2) {
    opacity: 0;
}

.menu-button.active span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
}

.menu {
    position: absolute;
    top: 80px;
    right: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-item {
    width: 100%;
    padding: 15px 20px;
    border: none;
    background: white;
    text-align: left;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
    color: #333;
}

.menu-item:hover {
    background: #f0f0f0;
}

.menu-item:active {
    background: #e0e0e0;
}

.menu-item.sync-enabled {
    background: #4CAF50;
    color: white;
}

.menu-item.sync-enabled:hover {
    background: #45a049;
}

.add-item-form {
    display: flex;
    gap: 10px;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

#itemInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

#itemInput:focus {
    outline: none;
    border-color: #667eea;
}

#prioritySelect {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

#prioritySelect:focus {
    outline: none;
    border-color: #667eea;
}

#addButton {
    padding: 12px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

#addButton:hover {
    background: #5568d3;
}

#addButton:active {
    transform: scale(0.98);
}

.shopping-list {
    list-style: none;
    padding: 0;
}

.shopping-list > .ghost-placeholder {
    animation: none !important;
    transition: none !important;
}

.item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
}

.item:not(.drag-over):not(:has(+ .ghost-placeholder)):not(.ghost-placeholder + *) {
    transition: all 0.2s;
}

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

/* Divider between completed and uncompleted items */
.completed-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 2px solid #e0e0e0;
    border-bottom: 2px solid #e0e0e0;
    list-style: none;
    pointer-events: none;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, #d0d0d0, transparent);
}

.divider-text {
    font-size: 12px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 8px;
    white-space: nowrap;
}

.item:hover {
    background: #f8f9fa;
}

.item.drag-over {
    border-top: 3px solid #667eea;
    background: #f0f4ff;
}

.sortable-ghost {
    opacity: 0.4;
}

.sortable-chosen {
    cursor: grabbing;
}

.sortable-drag {
    opacity: 0.8;
}

.ghost-item-content.priority-asap {
    background: rgba(255, 68, 68, 0.15);
    border-color: #ff4444;
}

.ghost-item-content.priority-soon {
    background: rgba(255, 215, 0, 0.15);
    border-color: #ffd700;
}

.ghost-item-content.priority-later {
    background: rgba(255, 255, 255, 0.3);
    border-color: #667eea;
}

.ghost-item-content input,
.ghost-item-content select {
    opacity: 0.7;
    pointer-events: none;
}

.dragging-ghost {
    pointer-events: none !important;
    background: white !important;
    border: 2px solid #667eea !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
}


/* Priority colors */
.item.priority-asap {
    background: #ff4444;
    color: white;
}

.item.priority-asap:hover {
    background: #ff3333;
}

.item.priority-asap .item-text,
.item.priority-asap .item-priority {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
}

.item.priority-asap .item-priority option {
    background: white;
    color: #333;
}

.item.priority-soon {
    background: #ffd700;
    color: #333;
}

.item.priority-soon:hover {
    background: #ffcc00;
}

.item.priority-later {
    background: #ffffff;
    color: #333;
}

.item.priority-later:hover {
    background: #f8f9fa;
}

/* Softened colors for checked items */
.item.checked {
    opacity: 0.6;
}

.item.checked.priority-asap {
    background: #ff8888;
}

.item.checked.priority-asap:hover {
    background: #ff7777;
}

.item.checked.priority-soon {
    background: #ffe880;
}

.item.checked.priority-soon:hover {
    background: #ffe066;
}

.item.checked.priority-later {
    background: #f5f5f5;
}

.item.checked.priority-later:hover {
    background: #eeeeee;
}

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

.item-text {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 22px;
    font-weight: 600;
    background: white;
    transition: border-color 0.3s;
}

.item-text:focus {
    outline: none;
    border-color: #667eea;
}

.item.priority-asap .item-text:focus {
    border-color: #cc0000;
}

.item.priority-soon .item-text:focus {
    border-color: #cc9900;
}

.item-priority {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.item-priority:focus {
    outline: none;
    border-color: #667eea;
}

.drag-handle {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    color: #999;
    font-size: 18px;
    line-height: 1;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    padding: 4px;
    transition: color 0.2s;
    touch-action: none;
    pointer-events: auto;
    -webkit-touch-callout: none;
}

.drag-handle:hover {
    color: #667eea;
}

.drag-handle:active {
    cursor: grabbing;
    color: #5568d3;
}


/* Responsive design */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    
    header {
        padding: 20px 15px;
    }
    
    header h1 {
        font-size: 1.5rem;
        padding-right: 40px;
    }
    
    .menu-button {
        top: 50% !important;
        right: 15px !important;
        transform: translateY(-50%) !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .menu {
        top: 60px;
        right: 15px;
        left: 15px;
        min-width: auto;
    }
    
    .add-item-form {
        flex-wrap: nowrap;
        gap: 8px;
    }
    
    #itemInput {
        flex: 1;
        min-width: 0;
        font-size: 14px;
        padding: 10px 12px;
    }
    
    #prioritySelect {
        flex-shrink: 0;
        width: 90px;
        min-width: 90px;
        font-size: 14px;
        padding: 10px 8px;
    }
    
    #addButton {
        flex-shrink: 0;
        width: auto;
        min-width: 60px;
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .item {
        flex-wrap: nowrap;
        padding: 12px 16px;
        gap: 8px;
        align-items: center;
    }
    
    .item input[type="checkbox"] {
        flex-shrink: 0;
        width: 20px;
        height: 20px;
    }
    
    .item-text {
        flex: 1;
        min-width: 0;
        font-size: 19px;
        font-weight: 600;
        padding: 6px 10px;
    }
    
    .item-priority {
        flex-shrink: 0;
        min-width: 80px;
        max-width: 100px;
        font-size: 13px;
        padding: 6px 8px;
    }
    
    .drag-handle {
        width: 20px;
        height: 20px;
        font-size: 16px;
        padding: 2px;
    }
}

/* Drag feedback */
.item[draggable="true"] {
    user-select: none;
}

.item:active {
    opacity: 0.5;
}

/* Pull to refresh indicator */
.refresh-indicator {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 1000;
    background: white;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 120px;
}

.refresh-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    transition: transform 0.2s ease;
    margin-bottom: 5px;
}

.refresh-spinner.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.refresh-text {
    font-size: 12px;
    color: #667eea;
    font-weight: 500;
    white-space: nowrap;
}

/* Visual feedback during pull */
.container.pulling {
    transition: transform 0.1s ease;
}

.container.pulling::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform-origin: left;
    z-index: 999;
}
