/* CSS Styles for Home Grocery Manager */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
}

/* Login Page Styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-form {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-form h1 {
    margin-bottom: 0.5rem;
    color: #333;
    font-size: 1.8rem;
}

.login-form p {
    margin-bottom: 1.5rem;
    color: #666;
}

.login-info {
    margin-top: 1rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 5px;
    color: #666;
}

/* Dashboard Styles */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-bottom: 2px solid #e9ecef;
}

header h1 {
    color: #2c3e50;
    font-size: 2rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Add Form */
.add-form {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.add-form h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

/* Button Styles */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Statistics */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
    border-left: 4px solid #667eea;
}

.stat-card.warning {
    border-left-color: #ffc107;
}

.stat-card.danger {
    border-left-color: #dc3545;
}

.stat-card.info {
    border-left-color: #007bff;
}

.stat-card h4 {
    margin-bottom: 0.5rem;
    color: #666;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
    display: block;
}

.stat-card small {
    color: #666;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: block;
}

/* Sections */
.section {
    margin-bottom: 2rem;
}

.section h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
    font-size: 1.5rem;
}

/* Items Grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.item-card {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-left: 3px solid #28a745;
    transition: transform 0.2s ease;
}

.item-card:hover {
    transform: translateY(-2px);
}

.item-card.expiring {
    border-left-color: #ffc107;
    background: #fff9c4;
}

.item-card.expired {
    border-left-color: #dc3545;
    background: #ffe6e6;
}

.item-card.never-expires {
    border-left-color: #007bff;
    background: #f8f9ff;
}

.item-info h4 {
    margin-bottom: 0.25rem;
    color: #2c3e50;
    font-size: 1rem;
    line-height: 1.2;
}

.item-location {
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.item-quantity {
    color: #007bff;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.item-dates {
    margin-bottom: 0.75rem;
}

.date-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.15rem;
    font-size: 0.85rem;
}

.date-label {
    font-weight: 600;
    color: #666;
}

.date-value {
    color: #333;
}

.expiry-status {
    margin-top: 0.25rem;
}

.status {
    padding: 0.2rem 0.6rem;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status.good {
    background: #d4edda;
    color: #155724;
}

.status.expiring {
    background: #fff3cd;
    color: #856404;
}

.status.expired {
    background: #f8d7da;
    color: #721c24;
}

.status.never-expires {
    background: #e7f3ff;
    color: #004085;
    border: 1px solid #b8daff;
}

.item-notes {
    margin-bottom: 0.75rem;
    padding: 0.4rem;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #666;
    line-height: 1.3;
}

.item-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.close:hover {
    color: #333;
}

/* Messages */
.error, .success {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.no-items {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

/* Master Items Styles */
.master-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.master-item-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-left: 4px solid #007bff;
    transition: transform 0.2s ease;
}

.master-item-card:hover {
    transform: translateY(-2px);
}

.master-item-info h4 {
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-size: 1.1rem;
}

.master-category {
    color: #007bff;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.master-defaults {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.default-info {
    background: #f8f9fa;
    padding: 0.25rem 0.5rem;
    border-radius: 15px;
    font-size: 0.8rem;
    color: #666;
}

.master-item-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Datalist styling improvements */
input[list] {
    position: relative;
}

/* Responsive adjustments for master items */
@media (max-width: 768px) {
    .master-items-grid {
        grid-template-columns: 1fr;
    }
    
    .master-item-actions {
        flex-direction: column;
    }
    
    .master-defaults {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .container {
        padding: 0.5rem;
    }
    
    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .items-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .item-card {
        padding: 0.75rem;
    }
    
    .item-actions {
        flex-direction: column;
    }
    
    .form-actions {
        flex-direction: column;
    }
}

/* Two-step form styles */
.form-step {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.item-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.item-header h4 {
    margin: 0;
    color: #2c3e50;
}

.btn-link {
    background: none;
    border: none;
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
}

.btn-link:hover {
    color: #0056b3;
}

/* Search results styles */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e9ecef;
    border-top: none;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f4;
    transition: background-color 0.2s ease;
}

.search-result-item:hover {
    background-color: #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item.new-item {
    background-color: #e8f4fd;
    border-left: 3px solid #007bff;
}

.search-result-item.new-item:hover {
    background-color: #d1ecf1;
}

.result-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.result-info {
    font-size: 0.85rem;
    color: #666;
}

.no-results {
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Parent/new item info alerts */
.parent-info, .new-item-info {
    margin-bottom: 1.5rem;
}

.alert {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.alert-info {
    background-color: #d1ecf1;
    border-left: 4px solid #bee5eb;
    color: #0c5460;
}

.alert-success {
    background-color: #d4edda;
    border-left: 4px solid #c3e6cb;
    color: #155724;
}

.alert strong {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.alert small {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    opacity: 0.8;
}

#parent-details {
    margin: 0.75rem 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

#parent-details div {
    margin-bottom: 0.25rem;
}

/* Form group positioning for search */
.form-group {
    position: relative;
}

/* Enhanced button styles */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn:disabled:hover {
    background-color: initial;
    transform: none;
}

/* Responsive adjustments for two-step form */
@media (max-width: 768px) {
    .item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .search-results {
        max-height: 200px;
    }
    
    .alert {
        padding: 0.75rem;
    }
    
    .form-step {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .alert strong {
        font-size: 1rem;
    }
    
    .result-name {
        font-size: 0.9rem;
    }
    
    .result-info {
        font-size: 0.8rem;
    }
    
    .items-grid {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }
    
    .item-card {
        padding: 0.6rem;
        border-radius: 6px;
    }
    
    .item-info h4 {
        font-size: 0.95rem;
        margin-bottom: 0.2rem;
    }
    
    .item-quantity, .item-location {
        font-size: 0.8rem;
    }
    
    .date-info {
        font-size: 0.8rem;
        margin-bottom: 0.1rem;
    }
    
    .status {
        font-size: 0.7rem;
        padding: 0.15rem 0.5rem;
    }
    
    .item-actions {
        gap: 0.3rem;
    }
    
    .btn-sm {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #666;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
}
