/* CSS Variables for theming (shadcn/ui inspired) */
:root {
    /* Light theme */
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;
    --card: 0 0% 100%;
    --card-foreground: 222.2 84% 4.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 222.2 84% 4.9%;
    --primary: 262.1 83.3% 57.8%;
    --primary-foreground: 210 40% 98%;
    --secondary: 210 40% 96%;
    --secondary-foreground: 222.2 84% 4.9%;
    --muted: 210 40% 96%;
    --muted-foreground: 215.4 16.3% 46.9%;
    --accent: 210 40% 96%;
    --accent-foreground: 222.2 84% 4.9%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 210 40% 98%;
    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 262.1 83.3% 57.8%;
    --radius: 0.5rem;
}

[data-theme="dark"] {
    /* Dark theme */
    --background: 222.2 84% 4.9%;
    --foreground: 210 40% 98%;
    --card: 222.2 84% 4.9%;
    --card-foreground: 210 40% 98%;
    --popover: 222.2 84% 4.9%;
    --popover-foreground: 210 40% 98%;
    --primary: 262.1 83.3% 57.8%;
    --primary-foreground: 210 40% 98%;
    --secondary: 217.2 32.6% 17.5%;
    --secondary-foreground: 210 40% 98%;
    --muted: 217.2 32.6% 17.5%;
    --muted-foreground: 215 20.2% 65.1%;
    --accent: 217.2 32.6% 17.5%;
    --accent-foreground: 210 40% 98%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 210 40% 98%;
    --border: 217.2 32.6% 17.5%;
    --input: 217.2 32.6% 17.5%;
    --ring: 262.1 83.3% 57.8%;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(var(--secondary)) 100%);
    min-height: 100vh;
    color: hsl(var(--foreground));
    transition: all 0.3s ease;
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, hsl(var(--background)) 0%, hsl(217.2 32.6% 12%) 100%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Top Controls */
.top-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px 20px;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .top-controls {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.controls-left,
.controls-right {
    display: flex;
    gap: 16px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-label {
    font-size: 14px;
    font-weight: 500;
    color: hsl(var(--foreground));
    white-space: nowrap;
}

.control-select {
    padding: 6px 12px;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}

.control-select:focus {
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.control-select:hover {
    border-color: hsl(var(--ring));
}

header {
    text-align: center;
    color: hsl(var(--primary-foreground));
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 30px;
}

@media (max-width: 968px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

.form-section,
.result-section {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

[data-theme="dark"] .form-section,
[data-theme="dark"] .result-section {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

h2 {
    color: hsl(var(--primary));
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid hsl(var(--border));
    padding-bottom: 10px;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 16px;
    margin-bottom: 20px;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.params-container {
    margin-bottom: 20px;
}

.param-group {
    margin-bottom: 15px;
}

.param-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
}

.param-group input,
.param-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.param-group input:focus,
.param-group select:focus {
    outline: none;
    border-color: #667eea;
}

.param-group small {
    display: block;
    margin-top: 5px;
    color: #888;
    font-size: 12px;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.btn-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: 1px solid transparent;
}

.btn-primary:hover:not(:disabled) {
    background: hsl(var(--primary) / 0.9);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px hsl(var(--primary) / 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border: 1px solid hsl(var(--border));
}

.btn-secondary:hover:not(:disabled) {
    background: hsl(var(--secondary) / 0.8);
    border-color: hsl(var(--border));
}

.url-display {
    margin-bottom: 20px;
    padding: 15px;
    background: hsl(var(--muted));
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
}

.url-display label {
    display: block;
    margin-bottom: 8px;
    color: hsl(var(--foreground));
    font-weight: 500;
}

.url-code {
    display: block;
    padding: 10px;
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    word-break: break-all;
    font-family: 'Courier New', monospace;
    color: hsl(var(--primary));
    font-size: 14px;
}

.response-container {
    min-height: 200px;
    padding: 20px;
    background: hsl(var(--muted));
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
}

.response-container .placeholder {
    color: hsl(var(--muted-foreground));
    text-align: center;
    padding: 40px;
    font-style: italic;
}

.response-success {
    background: hsl(120 60% 90%);
    border: 1px solid hsl(120 60% 80%);
    color: hsl(120 60% 20%);
    padding: 15px;
    border-radius: var(--radius);
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
    line-height: 1.6;
}

[data-theme="dark"] .response-success {
    background: hsl(120 30% 15%);
    border-color: hsl(120 30% 25%);
    color: hsl(120 60% 70%);
}

.response-error {
    background: hsl(0 60% 90%);
    border: 1px solid hsl(0 60% 80%);
    color: hsl(0 60% 20%);
    padding: 15px;
    border-radius: var(--radius);
    white-space: pre-wrap;
    word-wrap: break-word;
}

[data-theme="dark"] .response-error {
    background: hsl(0 30% 15%);
    border-color: hsl(0 30% 25%);
    color: hsl(0 60% 70%);
}

.loading {
    text-align: center;
    padding: 40px;
    color: #667eea;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: '.';
    }

    40% {
        content: '..';
    }

    60%,
    100% {
        content: '...';
    }
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.checkbox-group label {
    margin: 0;
    cursor: pointer;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin: 20px 0;
    justify-content: center;
    background: hsl(var(--muted));
    border-radius: var(--radius);
    padding: 4px;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    background: transparent;
    color: hsl(var(--muted-foreground));
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.tab-btn.active {
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    box-shadow: 0 1px 3px hsl(var(--border));
}

.hidden {
    display: none !important;
}

#twitchTab {
    grid-template-columns: 1fr;
}

#twitchTab.hidden {
    display: none !important;
}

/* Twitch Bot Section */
#twitchTab.main-content {
    grid-template-columns: 1fr;
}

.twitch-section {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 900px;
    margin: 0 auto;
    grid-column: 1 / -1;
    transition: all 0.3s ease;
}

[data-theme="dark"] .twitch-section {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.subtitle {
    color: hsl(var(--muted-foreground));
    margin-bottom: 25px;
    font-size: 14px;
}

.twitch-form {
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: hsl(var(--foreground));
    font-weight: 500;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: hsl(var(--muted-foreground));
    font-size: 12px;
}

.twitch-result {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid hsl(var(--border));
}

.twitch-result h3 {
    color: hsl(var(--primary));
    margin-bottom: 15px;
}

.command-display {
    position: relative;
    margin-bottom: 20px;
}

.command-code {
    display: block;
    padding: 15px;
    background: hsl(var(--muted));
    border: 2px solid hsl(var(--border));
    border-radius: 8px;
    word-break: break-all;
    font-family: 'Courier New', monospace;
    color: hsl(var(--foreground));
    font-size: 14px;
    line-height: 1.6;
    transition: all 0.3s ease;
    min-height: 60px;
    white-space: pre-wrap;
}

.copy-btn {
    margin-top: 10px;
    padding: 8px 16px;
    font-size: 14px;
}

.command-info {
    margin-top: 20px;
}

.command-info h4 {
    color: hsl(var(--primary));
    margin-bottom: 10px;
    font-size: 1.1em;
}

.usage-text {
    background: hsl(var(--muted));
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid hsl(var(--primary));
    color: hsl(var(--foreground));
    font-family: 'Courier New', monospace;
}

.setup-list {
    padding-left: 20px;
    color: hsl(var(--foreground));
    line-height: 1.8;
}

.setup-list li {
    margin-bottom: 8px;
}

.setup-list code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #667eea;
}

.copy-success {
    background: #d4edda !important;
    color: #155724 !important;
}

/* Generate Bot Command Button */
#generateBotCommandBtn {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    border: none;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
    display: inline-block;
}

#generateBotCommandBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(155, 89, 182, 0.4);
    background: linear-gradient(135deg, #a569bd 0%, #9b59b6 100%);
}

#generateBotCommandBtn:active {
    transform: translateY(0);
}

/* Notification Styling */
.notification {
    z-index: 1001;
}

.bot-notification {
    border-left: 4px solid #9b59b6;
}

/* Readonly Field Styling */
.readonly-field {
    background-color: hsl(var(--muted)) !important;
    color: hsl(var(--muted-foreground)) !important;
    cursor: not-allowed !important;
    border-color: hsl(var(--border)) !important;
}

.readonly-field:focus {
    border-color: hsl(var(--border)) !important;
    box-shadow: none !important;
}

/* Button States */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #ccc !important;
}

.btn.loading {
    position: relative;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Endpoint Description */
.endpoint-description {
    background: #f8f9ff;
    border: 1px solid #e1e5f2;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0 20px 0;
    border-left: 4px solid #667eea;
    animation: slideIn 0.3s ease-out;
}

.endpoint-description p {
    margin: 0;
    color: #555;
    line-height: 1.6;
    font-size: 14px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .footer {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.footer p {
    margin: 0;
    color: hsl(var(--muted-foreground));
    font-size: 14px;
}

.footer a {
    color: hsl(var(--primary));
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.footer a:hover {
    color: hsl(var(--ring));
    text-decoration: underline;
}
