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

:root {
    --primary-color: #89CFF0;
    --primary-dark: #5DADE2;
    --secondary-color: #FFB6C1;
    --success-color: #90EE90;
    --warning-color: #FFD700;
    --danger-color: #FF6B6B;
    --text-dark: #2C3E50;
    --text-light: #7F8C8D;
    --bg-light: #F8F9FA;
    --white: #FFFFFF;
    --border-color: #E1E8ED;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #E8F5E9 0%, #FFF9C4 100%);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    background: var(--white);
    padding: 30px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header-content {
    flex: 1;
}

.title {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 5px;
    font-weight: 700;
}

.subtitle {
    color: var(--text-light);
    font-size: 1.1rem;
}

/* Stats Bar */
.stats-bar {
    background: var(--white);
    padding: 20px 30px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.stats {
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Filter Buttons */
.filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 20px;
    border: 2px solid var(--border-color);
    background: var(--white);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-dark);
}

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

/* Items Grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.item-card {
    background: var(--white);
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.item-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.item-card.status-purchased {
    opacity: 0.7;
}

.item-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--bg-light);
}

.item-body {
    padding: 20px;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.item-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.available {
    background: #E8F5E9;
    color: #2E7D32;
}

.status-badge.partial {
    background: #FFF3E0;
    color: #E65100;
}

.status-badge.purchased {
    background: #E3F2FD;
    color: #1565C0;
}

.item-category {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 10px;
}

.item-description {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 15px;
}

.item-progress {
    margin-bottom: 10px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-light);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 5px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-light);
}

.item-contributors {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 5px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-dark);
}

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

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--white);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 900px;
}

.modal-header {
    padding: 25px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: var(--text-dark);
    font-size: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--text-dark);
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-weight: 600;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Link Fields */
.link-field {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    gap: 10px;
    margin-bottom: 10px;
    align-items: start;
}

.link-field input {
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
}

.remove-link-btn {
    padding: 10px 15px;
    background: var(--danger-color);
    color: var(--white);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.remove-link-btn:hover {
    background: #E74C3C;
}

/* Details Modal */
.details-body {
    padding: 30px;
}

.details-main {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.details-image {
    width: 100%;
    height: 300px;
    object-fit: cover;
    border-radius: 12px;
    background: var(--bg-light);
}

.details-description {
    color: var(--text-light);
    margin-bottom: 20px;
    line-height: 1.8;
}

.details-price {
    margin-bottom: 20px;
}

.price-label {
    color: var(--text-light);
    margin-right: 10px;
}

.price-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.progress-section {
    margin-bottom: 20px;
}

.shopping-links {
    margin-top: 20px;
}

.shopping-links h4 {
    margin-bottom: 10px;
    color: var(--text-dark);
}

.shopping-link {
    display: inline-block;
    padding: 8px 16px;
    background: var(--bg-light);
    color: var(--primary-dark);
    text-decoration: none;
    border-radius: 8px;
    margin-right: 10px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.shopping-link:hover {
    background: var(--primary-color);
    color: var(--white);
    transform: translateY(-2px);
}

.details-contributions {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.details-contributions h3 {
    margin-bottom: 15px;
    color: var(--text-dark);
}

.contribution-item {
    background: var(--white);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contribution-info {
    flex: 1;
}

.contributor-name {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.contribution-details {
    font-size: 0.9rem;
    color: var(--text-light);
}

.contribution-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success-color);
}

.contribute-section {
    background: var(--bg-light);
    padding: 20px;
    border-radius: 12px;
}

.contribute-section h3 {
    margin-bottom: 20px;
    color: var(--text-dark);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

/* AI Suggestion Section */
.ai-suggestion-section {
    margin-bottom: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #E8F5E9 0%, #E3F2FD 100%);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.ai-suggestion-section .btn {
    margin-bottom: 10px;
}

.ai-suggestion-section .help-text {
    margin: 0;
    font-size: 0.85rem;
    color: #1565C0;
}

/* Loading Overlay */
#loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

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

.loading-content {
    background: white;
    padding: 40px 60px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-message {
    color: var(--text-dark);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

/* Amount Input with Checkbox */
.amount-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-dark);
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-label span {
    line-height: 1.4;
}

#remainingAmountText {
    font-weight: 600;
    color: var(--primary-color);
}

#contributionAmount:read-only {
    background-color: #f0f0f0;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
    }

    .stats-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .stats {
        justify-content: space-around;
    }

    .items-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .details-main {
        grid-template-columns: 1fr;
    }

    .details-image {
        height: 250px;
    }

    .link-field {
        grid-template-columns: 1fr;
    }

    .loading-content {
        padding: 30px 40px;
    }

    .spinner {
        width: 50px;
        height: 50px;
    }
}
