/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    opacity: 0.9;
    font-size: 1rem;
}

/* Main Content */
main {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* Sections */
section {
    margin-bottom: 2rem;
}

section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Add Goal Section */
.add-goal-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

/* Forms */
.goal-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

@media (max-width: 500px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

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

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

.btn-secondary:hover {
    background: #cbd5e1;
}

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

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

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

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Goals Container */
.goals-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.empty-state p {
    color: var(--text-secondary);
}

/* Goal Card */
.goal-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.goal-card:hover {
    box-shadow: var(--shadow-lg);
}

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

.goal-info h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.goal-info .goal-amounts {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.goal-info .goal-amounts .current-amount {
    color: var(--success-color);
    font-weight: 600;
}

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

.goal-actions button {
    padding: 0.5rem;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

.goal-actions button:hover {
    background: var(--background);
}

.goal-actions .delete-btn:hover {
    background: #fee2e2;
    border-color: var(--danger-color);
}

/* Progress Bar */
.progress-container {
    margin-bottom: 1rem;
}

.progress-bar {
    height: 12px;
    background: var(--border-color);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #7c3aed);
    border-radius: 999px;
    transition: width 0.5s ease;
}

.progress-fill.complete {
    background: linear-gradient(90deg, var(--success-color), #34d399);
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.progress-percentage {
    font-weight: 600;
    color: var(--primary-color);
}

.progress-percentage.complete {
    color: var(--success-color);
}

/* Goal Footer */
.goal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.goal-deadline {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.goal-deadline.overdue {
    color: var(--danger-color);
}

.goal-deadline.near {
    color: var(--warning-color);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal.hidden {
    display: none;
}

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

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}

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

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

.modal-content form {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.modal-actions .btn {
    flex: 1;
}

/* Details Modal */
.details-content {
    padding: 1.5rem;
}

.details-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 500px) {
    .details-summary {
        grid-template-columns: repeat(4, 1fr);
    }
}

.summary-card {
    background: var(--background);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
}

.summary-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.summary-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Timeline Section */
.timeline-section {
    margin-bottom: 1.5rem;
}

.timeline-section h4,
.contributions-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.timeline-projection {
    background: var(--background);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.timeline-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.timeline-item:last-child {
    border-bottom: none;
}

.timeline-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.timeline-value {
    font-weight: 500;
    font-size: 0.875rem;
}

.timeline-value.positive {
    color: var(--success-color);
}

.timeline-value.negative {
    color: var(--danger-color);
}

.no-projection {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-style: italic;
}

/* Contributions List */
.contributions-list {
    max-height: 200px;
    overflow-y: auto;
}

.contribution-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--background);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
}

.contribution-info {
    display: flex;
    flex-direction: column;
}

.contribution-amount {
    font-weight: 600;
    color: var(--success-color);
}

.contribution-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.contribution-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

.contribution-delete {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
    opacity: 0.7;
}

.contribution-delete:hover {
    opacity: 1;
}

.no-contributions {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: center;
    padding: 1rem;
}

/* Footer */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 1rem;
    text-align: center;
}

footer p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive Adjustments */
@media (max-width: 640px) {
    header h1 {
        font-size: 1.5rem;
    }

    .add-goal-section {
        padding: 1rem;
    }

    .goal-card {
        padding: 1rem;
    }

    .goal-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .goal-actions {
        align-self: flex-end;
    }

    .goal-footer {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .goal-footer .btn {
        width: 100%;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Animation for goal cards */
.goal-card {
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Celebration animation for completed goals */
.goal-card.completed {
    border: 2px solid var(--success-color);
}

.goal-card.completed::before {
    content: '🎉';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 1.5rem;
}

.goal-card {
    position: relative;
}
