:root {
    --primary-color: #006837;
    --primary-hover: #008542;
    --secondary-color: #22c55e;
    --secondary-hover: #16a34a;
    --bg-color: #f9fafb;
    --text-color: #1f2937;
    --border-color: #e5e7eb;
    --card-bg: #ffffff;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --header-height: 70px;
    --sidebar-width: 300px;
}

[data-theme="dark"] {
    --bg-color: #111827;
    --text-color: #f9fafb;
    --border-color: #374151;
    --card-bg: #1f2937;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: var(--header-height);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    flex: 1;
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
}

.container.with-sidebar {
    margin-right: var(--sidebar-width);
    max-width: calc(1200px - var(--sidebar-width));
}

header {
    background-color: var(--primary-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    height: var(--header-height);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
}

.header-content > div {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-title {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    text-align: center;
    font-family: 'Cairo', sans-serif;
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 50px;
    width: auto;
}

.menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

.side-menu {
    position: fixed;
    right: -100%;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--card-bg);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 999;
    overflow-y: auto;
    padding-top: calc(var(--header-height) + 1rem);
    padding-bottom: 1rem;
}

.side-menu.active {
    right: 0;
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0 1rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.menu-close {
    background: var(--primary-color);
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.menu-close:hover {
    background-color: var(--primary-hover);
    transform: scale(1.1);
}

.menu-items {
    list-style: none;
    padding: 0 1rem;
}

.menu-item {
    margin-bottom: 0.75rem;
}

.menu-section-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 1.5rem 0 1rem;
    padding: 0 1rem;
    color: var(--primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s ease;
    border-radius: 0.5rem;
    position: relative;
    font-weight: 500;
}

.menu-link:hover, .menu-link.active {
    background-color: var(--border-color);
    transform: translateX(-4px);
}

.menu-link i, .menu-link svg {
    margin-left: 0.75rem;
    width: 20px;
    text-align: center;
    color: var(--primary-color);
}

.delete-list-btn {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
    position: absolute;
    left: 0.5rem;
}

.menu-link:hover .delete-list-btn {
    opacity: 1;
}

.add-list-btn {
    padding: 0.5rem;
    margin: 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background-color 0.3s ease;
    width: calc(100% - 2rem);
}

.add-list-btn:hover {
    background-color: var(--primary-hover);
}

.shop-lists {
    padding: 0;
    margin: 0;
    list-style: none;
}

.input-group {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.input-field {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: var(--card-bg);
    color: var(--text-color);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
    transition: background-color 0.2s;
    text-decoration: none;
}

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

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

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

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

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

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

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

.btn-danger:hover {
    background-color: #dc2626;
}

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

.btn-success:hover {
    background-color: #059669;
}

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

.btn-warning:hover {
    background-color: #d97706;
}

.btn-whatsapp {
    background-color: #25D366;
    color: white;
}

.btn-whatsapp:hover {
    background-color: #128C7E;
}

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

.btn-share:hover {
    background-color: #365899;
}

.search-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}

.mode-switch {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    background-color: var(--card-bg);
    padding: 0.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.mode-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    background: none;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mode-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.categories-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.category-tag {
    padding: 0.5rem 1rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-tag:hover {
    border-color: var(--primary-color);
}

.category-tag.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.category-tag .delete-btn {
    opacity: 0;
    transition: opacity 0.3s ease;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.category-tag:hover .delete-btn {
    opacity: 1;
}

.category-tag.active .delete-btn {
    color: white;
}

.add-category {
    padding: 0.5rem;
    background: none;
    border: 1px dashed var(--border-color);
    border-radius: 1rem;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.add-category:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.table-container {
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #f3f4f6;
    font-weight: 600;
    position: sticky;
    top: 0;
}

[data-theme="dark"] th {
    background-color: #374151;
}

tbody tr {
    transition: background-color 0.2s;
}

tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.completed {
    text-decoration: line-through;
    opacity: 0.7;
}

.selected-row {
    background-color: rgba(34, 197, 94, 0.1);
}

.action-btn {
    padding: 0.25rem;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    margin: 0 0.25rem;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.complete-btn {
    background-color: #dcfce7;
    color: #166534;
}

.complete-btn:hover {
    background-color: #bbf7d0;
}

.edit-btn {
    background-color: #dbeafe;
    color: #1e40af;
}

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

.delete-btn {
    background-color: #fee2e2;
    color: #991b1b;
}

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

.select-btn {
    background-color: #fef3c7;
    color: #92400e;
}

.select-btn:hover {
    background-color: #fde68a;
}

.editable-cell {
    position: relative;
    cursor: pointer;
}

.editable-cell:hover::after {
    content: '✎';
    position: absolute;
    right: 5px;
    color: var(--primary-color);
}

.inline-edit {
    width: 80px;
    padding: 2px 4px;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    font-size: inherit;
    font-family: inherit;
    position: relative;
    z-index: 2;
    background: var(--card-bg);
}

.summary {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.total {
    font-size: 1.25rem;
    font-weight: 600;
}

.actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.selected-items-container {
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1rem;
    margin-bottom: 1rem;
    display: none;
}

.selected-items-container.show {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

.selected-items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.selected-items-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
}

.selected-item {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    animation: fadeIn 0.3s ease-out;
}

.selected-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.selected-item .delete-btn {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.selected-item .delete-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.clear-selection {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notification {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: none;
    animation: slideIn 0.3s ease-out;
    z-index: 1000;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1100;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 0.5rem;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

footer {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: center;
    margin-top: auto;
}

/* Shared view styles */
.shared-view-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    background-color: var(--card-bg);
    border-radius: 0.5rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.shared-view-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.shared-view-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.shared-view-subtitle {
    color: #6b7280;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.shared-item {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    background-color: var(--card-bg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.shared-item:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.shared-item:last-child {
    margin-bottom: 0;
}

.shared-item-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.item-number {
    background-color: var(--primary-color);
    color: white;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.shared-item-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-color);
}

.shared-item-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1rem;
    background-color: rgba(0, 104, 55, 0.05);
    border-radius: 0.5rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.total-item {
    grid-column: 1 / -1;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border-color);
    margin-top: 0.5rem;
}

.info-label {
    font-weight: 600;
    color: #6b7280;
    font-size: 0.875rem;
}

.info-value {
    font-weight: 600;
    color: var(--text-color);
}

.total-value {
    color: var(--primary-color);
    font-size: 1.1rem;
}

.shared-summary {
    margin-top: 2rem;
    text-align: center;
    padding-top: 1.5rem;
    border-top: 2px dashed var(--border-color);
}

.shared-total {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.error-container {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--error-color);
}

.error-container i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-container h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.error-container p {
    margin-bottom: 2rem;
    color: #6b7280;
}

.loading-spinner {
    text-align: center;
    color: var(--primary-color);
    margin: 1rem 0;
}

.loading-spinner i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.share-link-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: #f3f4f6;
    padding: 0.5rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

[data-theme="dark"] .share-link-container {
    background-color: #374151;
}

.share-link-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 0.875rem;
    background-color: var(--card-bg);
    color: var(--text-color);
}

.copy-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.25rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.3s ease;
}

.copy-btn:hover {
    background-color: var(--primary-hover);
}

@keyframes slideIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
        padding: 0;
    }
    
    .container {
        max-width: none;
        margin: 0;
        padding: 0;
    }
    
    table {
        border-collapse: collapse;
    }
    
    th, td {
        border: 1px solid #ddd;
    }

    .table-container {
        box-shadow: none;
    }
    
    .shared-item {
        break-inside: avoid;
        margin-bottom: 1rem;
        border: 1px solid #ddd;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 60px;
        --sidebar-width: 260px;
    }

    .header-title {
        font-size: 1.2rem;
    }

    .container {
        padding: 1rem 0.75rem;
    }

    .container.with-sidebar {
        margin-right: 0;
        max-width: 100%;
    }

    .side-menu {
        width: 85%;
        max-width: 300px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .shared-item-details {
        grid-template-columns: 1fr;
    }
    
    .shared-view-container {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .actions {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 0.25rem;
        width: 100%;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    .actions button, .actions label {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 0.5rem;
        font-size: 0.875rem;
    }

    .actions button i, .actions label i {
        margin-left: 0.25rem;
    }

    .menu-section-title {
        font-size: 1rem;
    }
    
    .shared-view-title {
        font-size: 1.5rem;
    }
    
    .item-number {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.75rem;
    }
}

/* Animation for selection */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.pulse {
    animation: pulse 0.3s ease-in-out;
}

/* New item layout styles */
.item-row {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0.5rem 0;
}

.item-details {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.5rem;
}

.item-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.item-info {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px dashed var(--border-color);
    padding-top: 0.5rem;
}

.item-total {
    font-weight: 600;
    color: var(--primary-color);
}

.item-actions {
    display: flex;
    gap: 0.5rem;
}

/* Make sure table data takes full width */
#shoppingList td {
    padding: 0.75rem;
}