/* CSS Variables for Theme */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 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: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

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

html {
    scroll-behavior: smooth;
}

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

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

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

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: 10px;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.tagline {
    font-size: 1rem;
    opacity: 0.9;
    max-width: 500px;
    margin: 0 auto;
}

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

/* Input Section */
.input-section {
    margin-bottom: 2rem;
}

.input-container {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.input-container label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
    min-height: 150px;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea::placeholder {
    color: var(--text-secondary);
}

/* Button Group */
.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    flex: 1;
    min-width: 150px;
}

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

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    background: var(--surface);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

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

.btn-icon {
    font-size: 1.1rem;
}

/* Results Section */
.results-section {
    animation: fadeIn 0.5s ease;
}

.results-section.hidden {
    display: none;
}

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

.results-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

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

.overall-sentiment {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.sentiment-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.sentiment-value {
    font-weight: 700;
    font-size: 1.1rem;
}

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

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

.sentiment-value.neutral {
    color: var(--warning-color);
}

.sentiment-score {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Result Cards */
.result-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.result-card h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

/* Emotion Bars */
.emotion-bars {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.emotion-bar-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.emotion-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.emotion-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.emotion-icon {
    font-size: 1.2rem;
}

.emotion-percentage {
    font-weight: 600;
    color: var(--text-secondary);
}

.emotion-bar-track {
    height: 10px;
    background: var(--border-color);
    border-radius: 5px;
    overflow: hidden;
}

.emotion-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.8s ease;
}

/* Emotion Colors */
.emotion-joy .emotion-bar-fill { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.emotion-sadness .emotion-bar-fill { background: linear-gradient(90deg, #60a5fa, #3b82f6); }
.emotion-anger .emotion-bar-fill { background: linear-gradient(90deg, #f87171, #ef4444); }
.emotion-fear .emotion-bar-fill { background: linear-gradient(90deg, #a78bfa, #8b5cf6); }
.emotion-surprise .emotion-bar-fill { background: linear-gradient(90deg, #34d399, #10b981); }
.emotion-disgust .emotion-bar-fill { background: linear-gradient(90deg, #fb923c, #f97316); }
.emotion-trust .emotion-bar-fill { background: linear-gradient(90deg, #2dd4bf, #14b8a6); }
.emotion-anticipation .emotion-bar-fill { background: linear-gradient(90deg, #f472b6, #ec4899); }

/* Sentence Analysis */
.sentence-analysis-card {
    margin-top: 1.5rem;
}

.sentence-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 500px;
    overflow-y: auto;
}

.sentence-item {
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--border-color);
    transition: var(--transition);
}

.sentence-item:hover {
    box-shadow: var(--shadow);
}

.sentence-item.positive {
    border-left-color: var(--success-color);
    background: rgba(34, 197, 94, 0.05);
}

.sentence-item.negative {
    border-left-color: var(--danger-color);
    background: rgba(239, 68, 68, 0.05);
}

.sentence-item.neutral {
    border-left-color: var(--warning-color);
    background: rgba(245, 158, 11, 0.05);
}

.sentence-text {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.sentence-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.sentence-sentiment {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    background: var(--surface);
    border-radius: 100px;
    font-weight: 600;
}

.sentence-emotions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.emotion-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--surface);
    border-radius: 100px;
    font-size: 0.8rem;
}

/* Footer */
footer {
    background: var(--text-primary);
    color: white;
    padding: 1.5rem;
    text-align: center;
    margin-top: auto;
}

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

footer a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Scrollbar Styling */
.sentence-list::-webkit-scrollbar {
    width: 8px;
}

.sentence-list::-webkit-scrollbar-track {
    background: var(--border-color);
    border-radius: 4px;
}

.sentence-list::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

.sentence-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Loading State */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    header {
        padding: 1.5rem 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .logo-container {
        flex-direction: column;
        gap: 0.5rem;
    }

    .tagline {
        font-size: 0.9rem;
    }

    main {
        padding: 1rem;
    }

    .input-container {
        padding: 1rem;
    }

    .button-group {
        flex-direction: column;
    }

    .primary-btn,
    .secondary-btn {
        width: 100%;
    }

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

    .overall-sentiment {
        width: 100%;
        justify-content: center;
    }

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

    .chart-container {
        height: 250px;
    }

    .emotion-bars {
        grid-template-columns: 1fr;
    }

    .sentence-meta {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.25rem;
    }

    .tagline {
        font-size: 0.85rem;
    }

    .result-card {
        padding: 1rem;
    }

    .chart-container {
        height: 220px;
    }
}

/* Print Styles */
@media print {
    header {
        background: none;
        color: var(--text-primary);
        border-bottom: 2px solid var(--border-color);
    }

    .input-section {
        display: none;
    }

    .result-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--border-color);
    }

    footer {
        background: none;
        color: var(--text-primary);
        border-top: 1px solid var(--border-color);
    }

    footer a {
        color: var(--text-primary);
    }
}
