/* Project-Based Favorites Styles */

/* Panel Backdrop */
.panel-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 999;
}

.panel-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Archive Button Styles */
.archive-btn, .unarchive-btn {
    background: #9E9E9E;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s;
}

.archive-btn:hover {
    background: #757575;
}

.unarchive-btn {
    background: #4CAF50;
}

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

.project-list-item.archived {
    background: #f5f5f5;
    border-left: 3px solid #ccc;
}

/* Project Notification */
.project-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #4CAF50;
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 10000;
    font-size: 14px;
}

.project-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.project-notification.error {
    background: #f44336;
}

.project-notification.warning {
    background: #ff9800;
}

/* Enhanced Favorites Button */
.favorites-floating-btn .quantity-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff9800;
    color: white;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* Project Selector within Panel */
.panel-project-selector {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-project-selector select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.panel-project-selector .create-project-btn {
    padding: 8px 12px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.panel-project-selector .create-project-btn:hover {
    background: #45a049;
}

.panel-project-selector .manage-project-btn {
    padding: 8px 12px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}

.panel-project-selector .manage-project-btn:hover {
    background: #1976D2;
}

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

.project-dialog {
    background: white;
    border-radius: 8px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.project-dialog h3 {
    margin: 0 0 20px 0;
    color: #333;
}

.dialog-content {
    margin-bottom: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #555;
    font-size: 14px;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.category-input {
    margin-bottom: 8px;
}

.add-category-btn {
    padding: 6px 12px;
    background: #f0f0f0;
    border: 1px dashed #999;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    width: 100%;
    margin-top: 8px;
}

.add-category-btn:hover {
    background: #e8e8e8;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

/* Enhanced Favorites Panel */
.favorites-panel.project-mode {
    width: 650px;
    max-width: 90vw;
}

/* Project Container */
.project-container {
    margin-bottom: 20px;
}

/* Categories Container */
.categories-container {
    border-left: 2px solid #e0e0e0;
    margin-left: 10px;
    padding-left: 0;
    margin-top: 10px;
    position: relative;
}

.categories-container::before {
    content: '';
    position: absolute;
    left: -2px;
    top: -10px;
    width: 12px;
    height: 10px;
    border-left: 2px solid #e0e0e0;
    border-bottom: 2px solid #e0e0e0;
    border-bottom-left-radius: 8px;
}

/* Ensure proper scrolling in favorites list */
#favoritesList {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 200px;
    max-height: calc(100vh - 350px);
    padding-bottom: 20px;
}

/* Compact the sections above */
.export-actions {
    flex-shrink: 0;
    max-height: 60px;
    overflow: hidden;
}

.cloud-storage-section {
    flex-shrink: 0;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
}

.favorites-panel-header {
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 12px;
    margin-bottom: 12px;
}

/* Close Panel Button Styles */
.close-panel-btn {
    background: rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 2rem;
    font-weight: 300;
    cursor: pointer;
    color: #555;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.close-panel-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #dc2626;
    transform: rotate(90deg) scale(1.05);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.15);
}

.close-panel-btn:active {
    transform: rotate(90deg) scale(0.95);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.project-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.project-header h3 {
    margin: 0 0 10px 0;
    color: white;
    font-size: 18px;
    font-weight: 600;
}

.project-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: white;
    opacity: 0.95;
}

.project-stats span {
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

/* Category Sections - Nested under project */
.category-section {
    margin-left: 15px;
    margin-bottom: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    background: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    position: relative;
}

.category-header {
    background: #fafafa;
    padding: 8px 12px;
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    position: relative;
}

.category-header:hover {
    background: #f5f5f5;
}

/* Add a visual connector line */
.category-section::before {
    content: '';
    position: absolute;
    left: -17px;
    top: 50%;
    width: 10px;
    height: 1px;
    background: #e0e0e0;
    transform: translateY(-50%);
}

.category-header::before {
    content: '▶';
    margin-right: 8px;
    transition: transform 0.3s;
    display: inline-block;
    font-size: 10px;
    color: #888;
}

.category-header:not(.collapsed)::before {
    transform: rotate(90deg);
}

.category-count {
    font-size: 11px;
    color: #999;
    font-weight: normal;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 10px;
}

.category-items {
    transition: max-height 0.3s ease-out;
    overflow: hidden;
}

.category-items.collapsed {
    max-height: 0 !important;
    border-bottom: none;
}

.category-items {
    padding: 12px;
}

/* Project Item */
.project-item {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 10px;
    transition: box-shadow 0.2s;
    cursor: pointer;
    position: relative;
}

.project-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background: #fafafa;
}

.item-image {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 4px;
    overflow: hidden;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.item-details {
    flex: 1;
    min-width: 0;
    align-self: center;
}

.item-details h5 {
    margin: 0 0 4px 0;
    font-size: 14px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-details .botanical {
    font-size: 12px;
    color: #666;
    font-style: italic;
    margin: 0 0 4px 0;
}

.item-controls {
    display: flex;
    align-items: center;
    align-self: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Quantity Control */
.quantity-control {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: #f5f5f5;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: background 0.2s;
}

.qty-btn:hover {
    background: #e0e0e0;
}

.qty-input {
    width: 40px;
    height: 28px;
    border: none;
    text-align: center;
    font-size: 14px;
    -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Category Select */
.category-select {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    max-width: 120px;
}

/* Remove Button */
.remove-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #ff6b6b;
    background: white;
    color: #ff6b6b;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s;
}

.remove-btn:hover {
    background: #ff6b6b;
    color: white;
}

/* Item Notes */
.item-notes {
    flex-basis: 100%;
    padding: 8px;
    background: #f9f9f9;
    border-radius: 4px;
    font-size: 13px;
    color: #666;
    margin-top: 0;
}

/* No Project State */
.no-project {
    text-align: center;
    padding: 40px 20px;
}

.no-project p {
    color: #666;
    margin-bottom: 20px;
}

/* Quick Add Dialog */
.quick-add-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 10001;
    min-width: 350px;
}

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

.quick-add-header h4 {
    margin: 0;
    color: #333;
}

.close-quick-add {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 20px;
    color: #999;
}

.quick-add-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quick-add-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quick-add-row label {
    min-width: 80px;
    font-size: 14px;
    color: #555;
}

.quick-add-row input,
.quick-add-row select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.quick-add-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

/* Quick Add Dialog Button Styles */
#quickAddConfirm {
    background-color: #70B246;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

#quickAddConfirm:hover {
    background-color: #4A7C30;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

#quickAddConfirm:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#quickAddCancel {
    background-color: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 100px;
}

#quickAddCancel:hover {
    background-color: #e8e8e8;
    border-color: #ccc;
}

#quickAddRemove {
    background-color: #ff6b6b;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 100px;
}

#quickAddRemove:hover {
    background-color: #ff5252;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 0, 0, 0.15);
}

/* Mobile adjustments for quick-add buttons */
@media (max-width: 768px) {
    .quick-add-actions {
        flex-wrap: wrap;
    }
    
    #quickAddConfirm,
    #quickAddCancel,
    #quickAddRemove {
        flex: 1;
        min-width: 0;
        padding: 10px 16px;
        font-size: 14px;
    }
    
    #quickAddConfirm {
        order: 3;
        flex-basis: 100%;
        margin-top: 8px;
    }
}

/* Plant Card Enhancement */
.plant-card .project-indicator {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #4CAF50;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.plant-card .project-indicator .qty {
    background: rgba(255,255,255,0.3);
    padding: 2px 4px;
    border-radius: 3px;
}

/* Export Options */
.export-options {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.export-btn {
    flex: 1;
    padding: 8px 12px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

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

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

.export-btn.excel:hover {
    background: #45a049;
}

/* Project Management Dialog */
.project-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 10px;
    background: white;
}

.project-list-item.active {
    background: #f0f8f0;
    border-color: #4CAF50;
}

.project-list-item .project-info {
    flex: 1;
}

.project-list-item .project-info strong {
    display: block;
    margin-bottom: 4px;
    color: #333;
}

.project-list-item .project-info span {
    font-size: 13px;
    color: #666;
}

.project-list-item .project-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.project-list-item .switch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    margin: 0;
    min-width: 65px;
    background: #2196F3;
    color: white;
    border: 1px solid #2196F3;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.4;
    font-weight: 500;
    box-sizing: border-box;
    vertical-align: middle;
    text-align: center;
}

.project-list-item .switch-btn:hover {
    background: #1976D2;
}

.project-list-item .delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    margin: 0;
    background: white;
    color: #ff6b6b;
    border: 1px solid #ff6b6b;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.4;
    font-weight: 500;
    box-sizing: border-box;
    vertical-align: middle;
    text-align: center;
}

.project-list-item .delete-btn:hover {
    background: #ff6b6b;
    color: white;
}

.project-list-item .archive-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    margin: 0;
    background: #9E9E9E;
    color: white;
    border: 1px solid #9E9E9E;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.4;
    font-weight: 500;
    transition: background 0.2s;
    box-sizing: border-box;
    vertical-align: middle;
    text-align: center;
}

.project-list-item .archive-btn:hover {
    background: #757575;
}

.project-list-item .unarchive-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    margin: 0;
    background: #4CAF50;
    color: white;
    border: 1px solid #4CAF50;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.4;
    font-weight: 500;
    transition: background 0.2s;
    box-sizing: border-box;
    vertical-align: middle;
    text-align: center;
}

.project-list-item .unarchive-btn:hover {
    background: #45a049;
}

.project-list-item .active-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    margin: 0;
    min-width: 65px;
    background: #4CAF50;
    color: white;
    border: 1px solid #4CAF50;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    box-sizing: border-box;
    vertical-align: middle;
    text-align: center;
}

/* Dialog Action Buttons - Override conflicting styles */
.project-dialog .dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.project-dialog .dialog-actions .primary-btn,
.project-dialog .dialog-actions .secondary-btn {
    padding: 8px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background-image: none !important; /* Override gradient */
    transform: none !important; /* Override transform */
}

.project-dialog .dialog-actions .primary-btn {
    background-color: #4CAF50;
    color: white;
}

.project-dialog .dialog-actions .primary-btn:hover {
    background-color: #45a049;
    transform: none !important; /* Prevent scale on hover */
}

.project-dialog .dialog-actions .secondary-btn {
    background-color: white;
    color: #666;
    border: 1px solid #ddd;
}

.project-dialog .dialog-actions .secondary-btn:hover {
    background-color: #f5f5f5;
    border-color: #ccc;
}

/* Responsive Design */
@media (max-width: 768px) {
    
    .favorites-panel.project-mode {
        width: 100%;
        max-width: 100%;
    }
    
    .project-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .item-controls {
        width: 100%;
        justify-content: space-between;
        margin-top: 10px;
    }
    
    .category-select {
        max-width: none;
        flex: 1;
    }
}

/* Print Styles */
@media print {
    .project-selector-bar,
    .favorites-floating-btn,
    .remove-btn,
    .qty-btn,
    .add-category-btn {
        display: none !important;
    }
    
    .project-item {
        break-inside: avoid;
    }
    
    .category-section {
        break-inside: avoid;
    }
}