/* Main styles for Finnish Traffic Legislation Chatbot */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Noto+Color+Emoji&display=swap');

:root {
    --primary-blue: #08074d;
    --secondary-blue: #23519c;
    --accent-blue: #4271aa;
    --dark-blue: #0e1f50;
    --light-blue: #8da5e7;
    --success-green: #10b981;
    --warning-amber: #f59e0b;
    --error-red: #ef4444;
    --text-dark: #1f2937;
    --text-medium: #4b5563;
    --text-light: #6b7280;
    --background-light: #f8fafc;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #c5c5c53f 0%, #8789f846 100%);
    margin: 0;
    min-height: 100vh;
    line-height: 1.6;
    color: var(--text-dark);
    overflow-x: hidden;
}

/* Animated background elements */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 119, 198, 0.2) 0%, transparent 50%);
    z-index: -1;
    animation: backgroundFloat 20s ease-in-out infinite;
}

@keyframes backgroundFloat {
    0%, 100% { opacity: 1; transform: translateY(0px); }
    50% { opacity: 0.8; transform: translateY(-20px); }
}

/* Header banner */
.header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--dark-blue) 100%);
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 32px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    animation: headerShine 3s ease-in-out infinite;
}
.header .center-group {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 6px); /* lower by 6px; tweak the 6px as needed */
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: auto;
}

.header .logo {
  margin-right: auto; /* override previous margin-right:auto */
  font-size: 1.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header .logo img {
    height: 48px; /* adjust as needed */
    width: auto;
    display: block; 
}

.language-select {
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 2px;
    backdrop-filter: blur(10px);
}

.language-select select {
    font-family: 'Noto Color Emoji', sans-serif;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid transparent;
    padding: 10px 20px 10px 15px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-dark);
    transition: all 0.3s ease;
    min-width: 160px;
}

.language-select select:hover {
    background: var(--white);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.language-select select:focus {
    outline: none;
    border-color: var(--secondary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Container */
.container {
    max-width: 700px;
    margin: 40px auto;
    background: var(--white);
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
    padding: 40px;
    position: relative;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: containerFadeIn 0.8s ease-out;
}

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



h2 {
    text-align: center;
    color: var(--text-dark);
    margin-bottom: 32px;
    font-size: 2rem;
    font-weight: 600;
    position: relative;
    padding-bottom: 16px;
}

h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--secondary-blue), var(--accent-blue));
    border-radius: 2px;
}

form {
    margin-bottom: 32px;
}

label {
    font-weight: 500;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

#label-ask::before {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-right: 0px;
  background: url('/static/logo/favicon.svg') no-repeat center / contain;
  vertical-align: middle;
}

.input-container {
    margin-bottom: 20px;
}

.textarea-wrapper {
    position: relative;
    display: block;
}

textarea {
    width: 100%;
    height: 120px;
    border-radius: 16px;
    border: 2px solid #e5e7eb;
    padding: 16px;
    padding-right: 60px; /* Make room for speech button */
    font-size: 1rem;
    resize: vertical;
    background: #f8fafc;
    transition: all 0.3s ease;
    font-family: inherit;
    line-height: 1.5;
}

textarea:focus {
    border-color: var(--secondary-blue);
    outline: none;
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

textarea::placeholder {
    color: var(--text-light);
    font-style: italic;
}

button[type="submit"] {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    color: var(--white);
    border: none;
    border-radius: 16px;
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

button[type="submit"]::before {
    content: '🔍';
    font-size: 1.2rem;
}

button[type="submit"]:hover {
    background: linear-gradient(135deg, var(--dark-blue) 0%, var(--primary-blue) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

button[type="submit"]:active {
    transform: translateY(0);
}

button[type="submit"].loading {
    background: linear-gradient(135deg, var(--warning-amber) 0%, #f97316 100%);
    cursor: wait;
    pointer-events: none;
}

button[type="submit"].loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Speech button */
.read-text {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: var(--white);
    border: none;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    min-height: 36px;
}

.read-text:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.read-text svg {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.read-text .speech-text {
    display: inline;
    white-space: nowrap;
}

.read-text:hover svg {
    transform: scale(1.1);
}

.read-text.speaking {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    justify-content: center;
    padding: 0;
    animation: pulse 1.5s ease-in-out infinite;
}

.read-text.speaking .speech-text {
    display: none;
}

.read-text.speaking svg {
    margin: 0;
    animation: recordingPulse 0.8s ease-in-out infinite alternate;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes recordingPulse {
    from { transform: scale(1); filter: brightness(1); }
    to { transform: scale(1.1); filter: brightness(1.2); }
}

/* TTS Summary Button Animations */
@keyframes breathingAnimation {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
    }
    50% { 
        transform: scale(1.05); 
        box-shadow: 0 0 30px rgba(245, 158, 11, 0.6);
    }
}

/* TTS Button States */
.tts-button-default {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
}

.tts-button-playing {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    animation: breathingAnimation 2s ease-in-out infinite;
}

.tts-button-paused {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
}

/* Results section */
.result {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    padding: 24px;
    border-radius: 20px;
    margin-top: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid #bae6fd;
    animation: resultSlideIn 0.5s ease-out;
    position: relative;
    overflow: hidden;
}

.result::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--secondary-blue), var(--accent-blue));
}

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

.result h4 {
    color: var(--primary-blue);
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.result h4::before {
    content: '📖';
    font-size: 1.3rem;
}

.result b {
    color: var(--secondary-blue);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.result b#label-summary::before {
    content: '💡';
}

.result b#label-raw::before {
    content: '📄';
}

.summary-text {
    background: var(--white);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--secondary-blue);
    margin: 12px 0;
    line-height: 1.6;
}

.error {
    color: var(--error-red);
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1px solid #fecaca;
    border-radius: 16px;
    padding: 16px 20px;
    margin-top: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: errorShake 0.5s ease-in-out;
}

.error::before {
    content: '⚠️';
    font-size: 1.2rem;
}

@keyframes errorShake {
    0%, 20%, 40%, 60%, 80%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
}

.raw {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    padding: 20px;
    border-radius: 16px;
    margin-top: 16px;
    font-size: 0.95rem;
    color: #92400e;
    border: 1px solid #fed7aa;
    box-shadow: var(--shadow-sm);
}

pre {
    margin: 0;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.9rem;
    background: none;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

/* Loading states */
.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-top: 3px solid var(--secondary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    vertical-align: middle;
    margin-right: 12px;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        margin: 20px;
        padding: 24px;
        border-radius: 20px;
    }
    
    .header {
        padding: 0 20px;
        height: 60px;
    }
    
    .header .logo {
        font-size: 1.5rem;
    }
    
    .language-select select {
        min-width: 140px;
        padding: 8px 16px 8px 12px;
    }
    
    .read-text {
        top: 6px;
        right: 6px;
        padding: 6px 8px;
        font-size: 0.8rem;
        min-height: 32px;
    }
    
    .read-text.speaking {
        width: 40px;
        height: 40px;
    }
    
    h2 {
        font-size: 1.75rem;
        margin-bottom: 24px;
    }
    
    textarea {
        height: 100px;
        padding: 14px;
        padding-right: 50px; /* Adjust for smaller mobile button */
    }
    
    button[type="submit"] {
        padding: 14px 24px;
        font-size: 1rem;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus indicators for accessibility */
button:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--secondary-blue);
    outline-offset: 2px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Login page specific styles */
#login-form {
    max-width: 400px;
    margin: 40px auto;
    padding: 32px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#login-form .input-container {
    margin-bottom: 24px;
}

#login-form label {
    font-weight: 600;
    color: var(--text-dark);
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

#login-form input[type="text"],
#login-form input[type="password"] {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 1rem;
    background: #f8fafc;
    transition: all 0.3s ease;
    font-family: inherit;
    box-sizing: border-box;
}

#login-form input[type="text"]:focus,
#login-form input[type="password"]:focus {
    border-color: var(--secondary-blue);
    outline: none;
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

#login-form input[type="text"]::placeholder,
#login-form input[type="password"]::placeholder {
    color: var(--text-light);
    font-style: italic;
}

#login-btn {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    color: var(--white);
    border: none;
    border-radius: 12px;
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 8px;
}

#login-btn::before {
    content: '🔐';
    font-size: 1.2rem;
}

#login-btn:hover {
    background: linear-gradient(135deg, var(--dark-blue) 0%, var(--primary-blue) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

#login-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-md);
}

#login-btn:focus-visible {
    outline: 2px solid var(--secondary-blue);
    outline-offset: 2px;
}

/* Login page container adjustments */
body:has(#login-form) .container {
    text-align: center;
    padding: 60px 20px 40px;
}

body:has(#login-form) .container h2 {
    color: var(--primary-blue);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
}

body:has(#login-form) .container p {
    color: var(--text-medium);
    font-size: 1.1rem;
    margin-bottom: 40px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}
