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

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

body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

#dark-mode-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

#dark-mode-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

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

header {
    text-align: center;
    margin-bottom: 3rem;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.config-section, .results-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

body.dark-mode .config-section,
body.dark-mode .results-section {
    background: #2a2a3e;
    color: #e0e0e0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

h2 {
    color: #333;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
}

body.dark-mode h2 {
    color: #e0e0e0;
    border-bottom: 2px solid #7c4dff;
}

h3 {
    color: #555;
    margin: 1.5rem 0 1rem 0;
    font-size: 1.2rem;
}

body.dark-mode h3 {
    color: #b0b0b0;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
    font-weight: 500;
}

body.dark-mode label {
    color: #e0e0e0;
}

input[type="url"],
input[type="password"],
input[type="text"],
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background: white;
    color: #333;
}

body.dark-mode input[type="url"],
body.dark-mode input[type="password"],
body.dark-mode input[type="text"],
body.dark-mode textarea {
    background: #1a1a2e;
    border-color: #4a4a6e;
    color: #e0e0e0;
}

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

body.dark-mode input:focus,
body.dark-mode textarea:focus {
    border-color: #7c4dff;
    box-shadow: 0 0 0 3px rgba(124, 77, 255, 0.1);
}

textarea {
    resize: vertical;
    font-family: inherit;
}

.custom-params {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

body.dark-mode .custom-params {
    background: #1a1a2e;
}

.param-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.param-key,
.param-value {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: #333;
}

body.dark-mode .param-key,
body.dark-mode .param-value {
    background: #2a2a3e;
    border-color: #4a4a6e;
    color: #e0e0e0;
}

.remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
}

.remove-btn:hover {
    background: #c82333;
}

#add-param-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}

#add-param-btn:hover {
    background: #218838;
}

.stream-section {
    margin-bottom: 2rem;
}

.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
    background-color: #ccc;
    border-radius: 34px;
    transition: 0.3s;
    margin-right: 15px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .slider {
    background-color: #667eea;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

body.dark-mode .slider {
    background-color: #4a4a6e;
}

body.dark-mode input:checked + .slider {
    background-color: #7c4dff;
}

.toggle-label {
    color: #333;
    font-weight: 500;
}

body.dark-mode .toggle-label {
    color: #e0e0e0;
}

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

#send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

#send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#loading {
    text-align: center;
    padding: 2rem;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.cancel-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 1rem;
    transition: background-color 0.3s ease;
}

.cancel-btn:hover {
    background: #c82333;
}

.error-container {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 1.5rem;
    color: #721c24;
}

body.dark-mode .error-container {
    background: #2d1b1b;
    border-color: #5a2a2a;
    color: #ff6b6b;
}

.error-container h3 {
    color: #721c24;
    margin-bottom: 1rem;
}

body.dark-mode .error-container h3 {
    color: #ff6b6b;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    text-align: center;
}

body.dark-mode .metric-card {
    background: #1a1a2e;
    border-left-color: #7c4dff;
}

.metric-card h4 {
    color: #555;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

body.dark-mode .metric-card h4 {
    color: #b0b0b0;
}

.metric-card p {
    font-size: 1.8rem;
    font-weight: bold;
    color: #667eea;
    margin: 0;
}

body.dark-mode .metric-card p {
    color: #7c4dff;
}

.response-section {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
}

body.dark-mode .response-section {
    background: #1a1a2e;
}

.streaming-content {
    background: #f8f9fa;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    min-height: 120px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
    animation: pulse 2s infinite;
}

body.dark-mode .streaming-content {
    background: #1a1a2e;
    border-color: #7c4dff;
    box-shadow: 0 2px 8px rgba(124, 77, 255, 0.2);
}

@keyframes pulse {
    0% { border-color: #667eea; }
    50% { border-color: #764ba2; }
    100% { border-color: #667eea; }
}

body.dark-mode @keyframes pulse {
    0% { border-color: #7c4dff; }
    50% { border-color: #9c4dff; }
    100% { border-color: #7c4dff; }
}

#response-content {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
}

body.dark-mode #response-content {
    background: #2a2a3e;
    border-color: #4a4a6e;
    color: #e0e0e0;
}

#streaming-content {
    background: transparent;
    border: none;
    border-radius: 4px;
    padding: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    min-height: 60px;
    color: #333;
    animation: fadeIn 0.3s ease-in;
}

body.dark-mode #streaming-content {
    background: transparent;
    color: #e0e0e0;
}

@keyframes fadeIn {
    from { opacity: 0.8; }
    to { opacity: 1; }
}

/* Add cursor effect for active streaming */
.streaming-content.active-streaming #streaming-content::after {
    content: '▊';
    animation: blink 1s infinite;
    color: #667eea;
}

body.dark-mode .streaming-content.active-streaming #streaming-content::after {
    color: #7c4dff;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .param-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    header h1 {
        font-size: 2rem;
    }
}