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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #303E47;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 900px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 90vh;
    max-height: 800px;
}

header {
    background: #303E47;
    border-bottom: 6px solid #459F9F;
    color: white;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.header-title {
    text-align: left;
}

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

.secondary-btn {
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    color: white;
    cursor: pointer;
    font-size: 13px;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.24);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0;
}

.header-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.logo-img {
    height: 44px;
    width: auto;
    display: block;
}

.header-divider {
    width: 1px;
    height: 44px;
    background: rgba(255, 255, 255, 0.25);
    margin: 0 20px;
    flex-shrink: 0;
}

.user-info:not(:empty)::before {
    content: "\25CF\0020";
    color: #4caf50;
    font-size: 10px;
    vertical-align: middle;
    margin-right: 2px;
}

.user-info {
    font-size: 12px;
    opacity: 0.85;
}

header h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 2px;
    letter-spacing: -0.01em;
}

.subtitle {
    font-size: 11px;
    opacity: 0.75;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #F7F8F9;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: fadeIn 0.3s ease-in;
}

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

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user .message-content {
    background: #459F9F;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.message-content p {
    margin: 0;
    white-space: pre-wrap;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

.message.user .message-time {
    text-align: right;
}

.message-link-container {
    margin-top: 8px;
    padding: 0 4px;
}

.message-link {
    font-size: 12px;
    color: #459F9F;
    text-decoration: none;
    font-weight: 600;
}

.message-link:hover {
    text-decoration: underline;
}

/* Ticket lookup cards */
.ticket-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e8eaef;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}

.ticket-list::-webkit-scrollbar {
    width: 6px;
}

.ticket-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ticket-list::-webkit-scrollbar-thumb {
    background: #c0c4cc;
    border-radius: 3px;
}

.ticket-list::-webkit-scrollbar-thumb:hover {
    background: #459F9F;
}

a.ticket-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8f9fb;
    border: 1px solid #e2e6ed;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

a.ticket-card:hover {
    border-color: #459F9F;
    box-shadow: 0 2px 8px rgba(69, 159, 159, 0.10);
}

.ticket-card-id {
    font-weight: 600;
    color: #459F9F;
    white-space: nowrap;
    min-width: 55px;
}

.ticket-card-subject {
    flex: 1;
    color: #2f3a4a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ticket-card-status {
    background: #e8f5e9;
    color: #1b5e20;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.ticket-card-arrow {
    color: #459F9F;
    font-size: 14px;
    font-weight: 500;
}

.escalation-actions {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 4px;
}

.escalation-action-text {
    font-size: 12px;
    color: #555;
    line-height: 1.4;
}

.escalation-btn-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ticket-action-btn {
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.ticket-action-btn:hover {
    transform: translateY(-1px);
}

.ticket-action-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.ticket-action-btn.primary {
    background: #459F9F;
    color: white;
    box-shadow: 0 4px 12px rgba(69, 159, 159, 0.22);
}

.ticket-action-btn.secondary {
    background: #eef1f6;
    color: #2f3a4a;
    border: 1px solid #d7deea;
}

.ticket-status {
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.4;
}

.ticket-status.success {
    background: #e8f5e9;
    color: #1b5e20;
}

.ticket-status.neutral {
    background: #eef2f7;
    color: #324154;
}

.ticket-status.error {
    background: #ffebee;
    color: #b71c1c;
}

.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.chat-footer {
    text-align: center;
    font-size: 10px;
    letter-spacing: 0.07em;
    color: #aab0bb;
    padding: 8px 0 10px;
    background: white;
    border-top: 1px solid #f0f0f0;
}

.chat-footer strong {
    color: #303E47;
    text-decoration: none;
    font-weight: 800;
}

#chat-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

#message-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

#message-input:focus {
    border-color: #459F9F;
}

#send-button {
    width: 48px;
    height: 48px;
    border: none;
    background: #459F9F;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(69, 159, 159, 0.4);
}

#send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(69, 159, 159, 0.5);
}

#send-button:active {
    transform: scale(0.95);
}

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

.loading-indicator {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 12px 20px;
    border-radius: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    color: #459F9F;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #459F9F;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Username Modal */
.modal {
    display: flex;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h2 {
    margin-bottom: 16px;
    color: #333;
    font-size: 24px;
}

.modal-content p {
    margin-bottom: 24px;
    color: #666;
    font-size: 14px;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-content input {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.modal-content input:focus {
    border-color: #459F9F;
}

.modal-content button {
    padding: 12px 24px;
    background: #459F9F;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.modal-content button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(69, 159, 159, 0.4);
}

.user-info {
    font-size: 12px;
    margin-top: 8px;
    opacity: 0.8;
}

/* Feedback buttons */
.feedback-container {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}

.feedback-btn {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 36px;
}

.feedback-btn:hover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: scale(1.05);
}

.feedback-btn:active {
    transform: scale(0.95);
}

.feedback-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.feedback-thumbs-up:hover {
    border-color: #4caf50;
    background: #e8f5e9;
}

.feedback-thumbs-down:hover {
    border-color: #f44336;
    background: #ffebee;
}

/* Feedback modal specific styles */
#feedback-modal .modal-content {
    max-width: 500px;
}

#reason-codes-container {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

#reason-codes-container label {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

#reason-codes-container label:hover {
    border-color: #667eea;
}

#reason-codes-container input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .message {
        max-width: 85%;
    }
    
    header h1 {
        font-size: 24px;
    }

    header {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions {
        justify-content: flex-end;
    }
    
    .modal-content {
        padding: 30px 20px;
    }
}
