/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #333;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    overflow-x: hidden;
}

/* Typography */
h1 {
    color: #333;
    text-align: center;
    margin-bottom: 10px;
}

h2 {
    color: #555;
    margin-top: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 1.5rem;
}

/* Progress Bar */
.progress {
    text-align: center;
    margin: 20px 0;
    font-size: 18px;
    color: #666;
}

/* Export/Import Container */
.export-import-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.export-btn,
.import-btn,
.share-btn,
.reset-btn {
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.export-btn {
    background-color: #4CAF50;
    color: white;
}

.export-btn:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.import-btn {
    background-color: #2196F3;
    color: white;
}

.import-btn:hover {
    background-color: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.share-btn {
    background-color: #FF9800;
    color: white;
}

.share-btn:hover {
    background-color: #F57C00;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Share Dialog */
.share-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.share-dialog {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
}

.share-dialog h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
}

.share-dialog p {
    margin-bottom: 20px;
    color: #666;
}

.share-url-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.share-url-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    background-color: #f5f5f5;
}

.copy-btn {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    white-space: nowrap;
}

.copy-btn:hover {
    background-color: #45a049;
}

.close-btn {
    width: 100%;
    padding: 10px;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.close-btn:hover {
    background-color: #da190b;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 30px;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 500;
    z-index: 1000;
    animation: slideDown 0.3s ease;
}

.notification-success {
    background-color: #4CAF50;
    color: white;
}

.notification-error {
    background-color: #f44336;
    color: white;
}

.notification-info {
    background-color: #2196F3;
    color: white;
}

.notification-warning {
    background-color: #FF9800;
    color: white;
}

.notification.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
}

/* Category Section */
.category-section {
    margin-bottom: 30px;
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s;
}

.category-section:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.category-section h2:hover .category-actions {
    opacity: 1;
}

.category-title {
    flex-grow: 1;
}

.category-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.items-container {
    margin: 15px 0;
}

/* Checklist Item */
.checklist-item {
    background: #f9f9f9;
    padding: 12px;
    margin: 8px 0;
    border-radius: 5px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    cursor: move;
    transition: all 0.2s;
    overflow: hidden;
}

.checklist-item:hover {
    background: #f5f5f5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.checklist-item:hover .item-actions {
    opacity: 1;
}

.checklist-item.checked {
    opacity: 0.6;
}

.checklist-item.checked .item-label {
    text-decoration: line-through;
}

/* Form Elements */
.item-checkbox {
    margin-right: 10px;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.item-label {
    cursor: pointer;
    flex-grow: 1;
    font-size: 16px;
}

/* Actions */
.item-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

/* Mobile Sort Buttons - Hidden by default */
.mobile-sort-buttons {
    display: none;
}

.sort-up-btn,
.sort-down-btn {
    padding: 6px 10px;
    border: none;
    border-radius: 3px;
    background-color: #6c757d;
    color: white;
    cursor: pointer;
    font-size: 14px;
    min-width: 32px;
    transition: background-color 0.2s;
}

.sort-up-btn:hover,
.sort-down-btn:hover {
    background-color: #5a6268;
}

.item-actions button,
.category-actions button {
    padding: 5px 10px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

/* Buttons */
.edit-btn {
    background-color: #2196F3;
    color: white;
}

.edit-btn:hover {
    background-color: #1976D2;
}

.delete-btn {
    background-color: #f44336;
    color: white;
}

.delete-btn:hover {
    background-color: #d32f2f;
}

/* Add Item Section */
.add-item {
    display: flex;
    margin-top: 15px;
    gap: 5px;
}

.add-item-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.add-item-input:focus {
    outline: none;
    border-color: #4CAF50;
}

.add-item-btn {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

.add-item-btn:hover {
    background-color: #45a049;
}

/* Add Category */
.add-category-container {
    text-align: center;
    margin: 30px 0;
}

.add-category-btn {
    padding: 12px 24px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

.add-category-btn:hover {
    background-color: #45a049;
}

.reset-btn {
    background-color: #dc3545;
    color: white;
}

.reset-btn:hover {
    background-color: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(220, 53, 69, 0.3);
}

/* Edit Inputs */
.edit-input,
.edit-category-input {
    padding: 5px 10px;
    border: 2px solid #2196F3;
    border-radius: 3px;
    font-size: 16px;
}

.edit-category-input {
    font-size: 24px;
    font-weight: 600;
    color: #555;
    margin-right: 10px;
}

/* Drag and Drop */
.drag-handle {
    cursor: move;
    color: #999;
    margin-right: 10px;
    font-size: 20px;
    transition: color 0.2s;
}

.drag-handle:hover {
    color: #666;
}

.dragging {
    opacity: 0.5;
}

.drag-over-top {
    border-top: 3px solid #4CAF50;
}

.drag-over-bottom {
    border-bottom: 3px solid #4CAF50;
}

/* Print Styles */
@media print {
    .add-item,
    .item-actions,
    .category-actions,
    .add-category-container,
    .drag-handle {
        display: none !important;
    }

    .category-section {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }

    .checklist-item {
        box-shadow: none;
        border: 1px solid #eee;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    h1 {
        font-size: 1.8rem;
        margin-bottom: 15px;
    }

    .progress {
        font-size: 16px;
        margin: 15px 0;
    }

    /* Export/Import/Share Buttons - Stack vertically on mobile */
    .export-import-container {
        flex-direction: column;
        gap: 8px;
        margin: 15px 0;
    }

    .export-btn,
    .import-btn,
    .share-btn,
    .reset-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
        font-size: 15px;
    }

    /* Category sections */
    h2 {
        font-size: 1.3rem;
        padding: 8px 0;
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 8px;
        align-items: center;
    }

    .category-title {
        grid-column: 1;
        grid-row: 1;
        min-width: 0;
        word-break: break-word;
    }

    .mobile-sort-buttons {
        grid-column: 2;
        grid-row: 1;
        display: flex;
        gap: 4px;
    }

    .category-actions {
        grid-column: 1 / -1;
        grid-row: 2;
        display: flex;
        justify-content: flex-start;
        gap: 8px;
    }

    .category-section {
        padding: 12px;
        margin-bottom: 20px;
        overflow: hidden;
    }

    /* Checklist items - Better touch targets */
    .checklist-item {
        padding: 10px 8px;
        min-height: 48px; /* iOS touch target recommendation */
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
    }

    .item-checkbox {
        width: 24px;
        height: 24px;
        flex-shrink: 0;
    }

    .item-label {
        font-size: 16px;
        line-height: 1.4;
        padding: 4px 0;
        flex: 1;
        min-width: 0;
        word-break: break-word;
    }

    .checklist-item .mobile-sort-buttons {
        display: flex;
        gap: 2px;
        flex-shrink: 0;
    }

    .checklist-item .mobile-sort-buttons button {
        padding: 4px 8px;
        min-width: 28px;
        font-size: 12px;
    }

    /* Always show actions on mobile */
    .item-actions,
    .checklist-item:hover .item-actions {
        opacity: 1;
        gap: 4px;
        flex-shrink: 0;
    }

    .item-actions button,
    .category-actions button {
        padding: 6px 10px;
        font-size: 12px;
        min-width: auto;
        min-height: 32px;
    }

    /* Add item input */
    .add-item {
        flex-wrap: wrap;
        gap: 8px;
    }

    .add-item-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
        width: 100%;
    }

    .add-item-btn {
        width: 100%;
        padding: 12px;
        font-size: 16px;
    }

    /* Add category button */
    .add-category-btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 15px;
    }

    /* Reset button container */
    .reset-container {
        margin-top: 40px;
        padding-top: 20px;
    }

    /* Share dialog */
    .share-dialog {
        padding: 20px;
        margin: 10px;
    }

    .share-url-container {
        flex-direction: column;
        gap: 8px;
    }

    .share-url-input {
        font-size: 14px;
        padding: 12px;
    }

    .copy-btn {
        width: 100%;
        padding: 12px;
    }

    /* Hide drag handles on mobile */
    .drag-handle {
        display: none;
    }

    /* Edit inputs */
    .edit-input,
    .edit-category-input {
        font-size: 16px;
        padding: 8px;
    }
}

/* Small mobile devices */
@media (max-width: 400px) {
    h1 {
        font-size: 1.5rem;
    }

    .container {
        padding: 8px;
    }

    .category-section {
        padding: 10px;
    }

    .item-actions button,
    .category-actions button {
        min-width: auto;
        font-size: 11px;
        padding: 5px 8px;
    }
    
    /* Even smaller sort buttons on very small screens */
    .mobile-sort-buttons button {
        padding: 3px 6px;
        min-width: 24px;
        font-size: 11px;
    }
    
    /* Stack buttons if needed */
    .checklist-item {
        flex-wrap: wrap;
    }
    
    .item-actions {
        width: 100%;
        margin-top: 8px;
        justify-content: flex-end;
    }
}