/* Reset and base styles */
* {
    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: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
}

header h1 {
    font-size: 2em;
    margin-bottom: 20px;
}

.header-controls {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* Language switcher group */
.control-group-lang {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* List selector group — takes remaining space */
.control-group-list {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.control-group-list label {
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.control-group-list select {
    flex: 1;
    min-width: 0;          /* allow shrinking below content width */
    padding: 8px 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1em;
    cursor: pointer;
}

.control-group-list select option {
    background: #764ba2;
    color: white;
}

.list-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-icon {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-icon {
    padding: 6px 8px;
    background: transparent;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    transition: transform 0.2s;
    line-height: 1;
}

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #667eea;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions button {
    flex: 1;
}

/* Sections */
section {
    padding: 30px;
}

.add-item-section {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.add-item-section h2, .items-section h2, .action-log-section h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
}

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

.items-count {
    color: #6c757d;
    font-size: 0.9em;
}

/* Forms */
.form-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.form-group {
    margin-bottom: 15px;
}

.form-group.flex-grow {
    flex: 1;
    min-width: 200px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
}

.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* Autocomplete */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #667eea;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.autocomplete-dropdown.hidden {
    display: none;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.autocomplete-item:hover {
    background: #f8f9fa;
}

.autocomplete-item .count {
    color: #6c757d;
    font-size: 0.85em;
}

/* Quantity input */
.quantity-input {
    display: flex;
    align-items: center;
    gap: 5px;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s;
}

.qty-btn:hover {
    background: #667eea;
    color: white;
}

.quantity-input input {
    width: 60px;
    text-align: center;
}

/* Items list */
.items-list {
    list-style: none;
}

.item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.item:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.item.checked {
    background: #f8f9fa;
    opacity: 0.6;
}

.item.checked .item-name {
    text-decoration: line-through;
    color: #6c757d;
}

.item-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

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

.item-text {
    min-width: 0;
}

.item-name {
    font-size: 1.1em;
    font-weight: 500;
}

.quantity-badge {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 700;
    margin-left: 10px;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.btn-danger {
    background: #dc3545;
    color: white;
    font-weight: 600;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
}

.btn-modal-cancel {
    padding: 10px 20px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8f9fa;
    color: #495057;
    font-weight: 500;
}

.btn-modal-cancel:hover {
    background: #e9ecef;
}

.item-notes {
    color: #6c757d;
    font-size: 0.9em;
    margin-top: 4px;
}

.item-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

/* Loading and empty states */
.loading, .empty-state {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.hidden {
    display: none;
}

/* Action log */
.action-log {
    max-height: 300px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
}

.action-item {
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 6px;
    font-size: 0.9em;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.action-user {
    font-weight: 600;
    color: #667eea;
}

.action-text {
    color: #6c757d;
}

.action-item-name {
    font-weight: 500;
}

.action-time {
    margin-left: auto;
    color: #adb5bd;
    font-size: 0.85em;
}

.empty-log {
    text-align: center;
    color: #adb5bd;
    padding: 20px;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    font-size: 0.9em;
    background: #f8f9fa;
}

/* ─── Responsive: tablet & mobile (≤ 768px) ─────────────────────────────── */
@media (max-width: 768px) {
    /* No gradient backdrop — container fills the screen */
    body {
        background: white;
        padding: 0;
        min-height: 100dvh;
    }

    .container {
        max-width: 100%;
        border-radius: 0;
        box-shadow: none;
        min-height: 100dvh;
    }

    /* Header */
    header {
        padding: 16px;
    }

    header h1 {
        font-size: 1.5em;
        margin-bottom: 14px;
    }

    .header-controls {
        flex-direction: column;
        gap: 10px;
    }

    .control-group-lang {
        width: 100%;
        justify-content: stretch;
    }

    .control-group-lang .btn-primary,
    .control-group-lang .btn-secondary {
        flex: 1;
        text-align: center;
    }

    .control-group-list {
        flex-wrap: wrap;
        gap: 8px;
    }

    .control-group-list label {
        width: 100%;
    }

    .control-group-list select {
        flex: 1;
        min-width: 0;
    }

    /* Sections */
    section {
        padding: 16px;
    }

    .form-row {
        flex-direction: column;
    }

    /* Items */
    .item {
        padding: 12px;
    }

    .item-actions {
        margin-left: auto;
    }

    /* Action log */
    .action-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .action-time {
        margin-left: 0;
    }

    /* Modal */
    .modal-content {
        width: 95%;
        padding: 20px;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}
