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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

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

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* Main Layout */
main {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
    margin-bottom: 40px;
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* Submission Section */
.submission-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    height: fit-content;
}

.form-container h2 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

#feelingsText {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

#feelingsText:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
}

.char-counter {
    font-size: 0.9rem;
    color: #718096;
}

#submitBtn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#submitBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#submitBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Message Styles */
.message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.message.success {
    background: #f0fff4;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.message.error {
    background: #fff5f5;
    color: #742a2a;
    border: 1px solid #feb2b2;
}

.hidden {
    display: none;
}

/* Word Cloud Section */
.wordcloud-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.wordcloud-container h2 {
    color: #4a5568;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: #718096;
}

.word-chart {
    width: 100%;
    height: 600px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fafafa;
    padding: 20px;
    overflow-y: auto;
}

.word-bar {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px 0;
}

.word-label {
    width: 120px;
    font-weight: 600;
    font-size: 14px;
    color: #4a5568;
    text-align: right;
    padding-right: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.word-bar-fill {
    height: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    color: white;
    font-weight: bold;
    font-size: 12px;
    min-width: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.word-bar-fill:hover {
    transform: translateX(2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Sentiment-specific styling */
.word-bar-fill.positive {
    background: #22c55e !important;
}

.word-bar-fill.negative {
    background: #ef4444 !important;
}

.word-bar-fill.neutral {
    background: #eab308 !important;
}

.chart-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.chart-title {
    font-size: 16px;
    font-weight: bold;
    color: #4a5568;
}

.chart-subtitle {
    font-size: 12px;
    color: #718096;
}

.sentiment-legend {
    display: flex;
    gap: 15px;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #4a5568;
    font-weight: 500;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.legend-color.positive {
    background-color: #22c55e;
}

.legend-color.negative {
    background-color: #ef4444;
}

.legend-color.neutral {
    background-color: #eab308;
}

.loading {
    text-align: center;
    color: #718096;
    font-style: italic;
    margin-top: 20px;
}

/* Footer */
footer {
    text-align: center;
    color: white;
    opacity: 0.8;
    font-size: 0.9rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.submission-section, .wordcloud-section {
    animation: fadeIn 0.6s ease-out;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .submission-section, .wordcloud-section {
        padding: 20px;
    }
    
    .word-chart {
        height: 450px;
        padding: 15px;
    }
    
    .word-label {
        width: 80px;
        font-size: 12px;
    }
    
    .sentiment-legend {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .legend-item {
        font-size: 10px;
    }
}

/* Loading spinner for submit button */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
