* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Heraldická paleta Světlé Hory */
    --primary: #1E3A8A;         /* modrá štítu */
    --primary-light: #3B5BD0;
    --primary-dark: #122257;
    --gold: #F5C518;            /* zlaté slunce */
    --gold-light: #FFD54F;
    --gold-dark: #C99C00;
    --silver: #C8CDD4;          /* stříbrný měsíc / hvězdy */
    --silver-light: #E9EBEF;

    --bg: #F5F7FC;
    --white: #ffffff;
    --gray-50: #F8FAFD;
    --gray-100: #EDF0F6;
    --gray-200: #D7DCE6;
    --gray-300: #A2A9B8;
    --gray-500: #6B7489;
    --gray-700: #38405B;
    --gray-900: #12173B;

    --shadow-sm: 0 1px 3px rgba(18, 35, 87, 0.08);
    --shadow-md: 0 4px 14px rgba(18, 35, 87, 0.12);
    --shadow-lg: 0 12px 40px rgba(18, 35, 87, 0.18);

    --radius: 12px;
    --radius-lg: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(30, 58, 138, 0.08), transparent 60%),
        radial-gradient(800px 500px at 95% 100%, rgba(245, 197, 24, 0.07), transparent 60%),
        var(--bg);
    color: var(--gray-900);
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.chat-container {
    width: 100%;
    max-width: 800px;
    height: 100%;
    max-height: 900px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(18, 35, 87, 0.08);
}

/* Header */
.chat-header {
    background:
        radial-gradient(600px 200px at 85% -30%, rgba(245, 197, 24, 0.25), transparent 70%),
        linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 55%, var(--primary-light) 100%);
    padding: 18px 22px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.chat-header::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold) 25%, var(--gold-light) 50%, var(--gold) 75%, transparent);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.header-text h1 {
    color: var(--white);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.subtitle {
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.reset-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    padding: 8px;
    color: var(--white);
    cursor: pointer;
    transition: all 0.2s;
}

.reset-btn:hover {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--primary-dark);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Email modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(18, 34, 87, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
    animation: modalFade 0.18s ease;
}

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

.modal-card {
    background: #FFFFFF;
    border-radius: 14px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(18, 34, 87, 0.25);
    overflow: hidden;
    border: 1px solid var(--silver);
    animation: modalSlide 0.22s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    border-bottom: 3px solid var(--gold);
}

.modal-header h3 {
    margin: 0;
    color: var(--white);
    font-size: 1.05rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--gold);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s;
}

.modal-close:hover { color: var(--white); }

.modal-body {
    padding: 20px 22px 8px;
}

.modal-body p {
    margin: 0 0 14px;
    color: var(--gray-700);
    font-size: 0.9rem;
    line-height: 1.5;
}

.modal-body label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.modal-body input[type="email"] {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--silver);
    border-radius: 9px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--primary-dark);
    background: var(--silver-light);
    transition: border-color 0.15s, background 0.15s;
    box-sizing: border-box;
}

.modal-body input[type="email"]:focus {
    outline: none;
    border-color: var(--primary);
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}

.modal-error {
    min-height: 18px;
    margin-top: 8px;
    font-size: 0.82rem;
    color: #C53030;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 22px 20px;
}

.modal-actions .btn-primary,
.modal-actions .btn-secondary {
    border: none;
    border-radius: 9px;
    padding: 10px 18px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.modal-actions .btn-primary {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: var(--gold);
    border: 1px solid var(--primary);
}

.modal-actions .btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.modal-actions .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.modal-actions .btn-secondary {
    background: var(--silver-light);
    color: var(--primary-dark);
    border: 1px solid var(--silver);
}

.modal-actions .btn-secondary:hover {
    background: var(--silver);
}

.chat-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translate(-50%, 20px);
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: var(--gold);
    padding: 12px 22px;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(18, 34, 87, 0.3);
    border-left: 3px solid var(--gold);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 1100;
}

.chat-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.chat-toast-warning {
    background: linear-gradient(135deg, #7A5A00, #A87A00);
    color: #FFFFFF;
    border-left-color: var(--gold-light);
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    background:
        radial-gradient(400px 300px at 0% 0%, rgba(30, 58, 138, 0.03), transparent 70%),
        var(--white);
}

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--gray-200);
    border-radius: 3px;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.bot-message { align-self: flex-start; }
.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    padding: 4px;
    box-shadow: 0 2px 6px rgba(30, 58, 138, 0.25);
}

.bot-message .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.user-message .message-avatar {
    background: var(--gold);
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 0.9rem;
}

.message-content {
    padding: 12px 16px;
    border-radius: var(--radius);
    line-height: 1.55;
    font-size: 0.925rem;
}

.bot-message .message-content {
    background: var(--gray-50);
    border: 1px solid var(--gray-100);
    border-top-left-radius: 4px;
    color: var(--gray-900);
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: var(--white);
    border-top-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.25);
}

.message-content p { margin-bottom: 8px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content strong { font-weight: 600; color: var(--primary-dark); }
.user-message .message-content strong { color: var(--gold-light); }

.message-content ul, .message-content ol { margin: 8px 0; padding-left: 20px; }
.message-content li { margin-bottom: 4px; }

.message-content a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: var(--gold);
    text-decoration-thickness: 2px;
}

.user-message .message-content a {
    color: var(--gold-light);
    text-decoration-color: rgba(255, 255, 255, 0.6);
}

/* Suggestions */
.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.suggestions-follow {
    border-top: 1px solid var(--gray-100);
    padding-top: 10px;
}

.suggestion-btn {
    background: var(--white);
    border: 1px solid var(--primary);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.825rem;
    font-family: inherit;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.suggestion-btn:hover {
    background: var(--primary);
    color: var(--gold);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(30, 58, 138, 0.18);
}

/* Sources */
.sources {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sources-label {
    font-size: 0.72rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.sources-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.source-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 8px;
    background: var(--silver-light);
    color: var(--primary);
    text-decoration: none;
    border: 1px solid var(--silver);
    transition: all 0.15s;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.source-chip:hover {
    background: var(--primary);
    color: var(--gold);
    border-color: var(--primary);
}

.source-chip-plain {
    cursor: default;
    color: var(--gray-700);
}

.source-chip-plain:hover {
    background: var(--silver-light);
    color: var(--gray-700);
    border-color: var(--silver);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--gold);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; background: var(--primary); }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; background: var(--silver); }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
.chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-100);
    background: var(--white);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(30, 58, 138, 0.08);
}

textarea {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.925rem;
    color: var(--gray-900);
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.5;
    padding: 4px 0;
}

textarea::placeholder { color: var(--gray-300); }

#sendBtn {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
    border-radius: 10px;
    padding: 8px 10px;
    color: var(--gold);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(30, 58, 138, 0.2);
}

#sendBtn:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

#sendBtn:disabled {
    background: var(--gray-200);
    color: var(--gray-500);
    cursor: not-allowed;
    box-shadow: none;
}

.disclaimer {
    text-align: center;
    font-size: 0.72rem;
    color: var(--gray-500);
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
}

.disclaimer a {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-color: var(--gold);
    font-weight: 500;
}

.live-dot {
    width: 6px;
    height: 6px;
    background: var(--gold);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px rgba(245, 197, 24, 0.6);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(245, 197, 24, 0.6); }
    50% { opacity: 0.5; box-shadow: 0 0 12px rgba(245, 197, 24, 0.9); }
}

/* Responsive */
@media (max-width: 640px) {
    body { padding: 0; }
    .chat-container {
        max-height: 100%;
        border-radius: 0;
        border: none;
    }
    .message { max-width: 92%; }
    .chat-header { padding: 14px 16px; }
    .chat-messages { padding: 14px; }
    .chat-input-area { padding: 12px 16px; }
}
