:root {
    /* Metallic & Glass Palette */
    --bg-gradient: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(12px);

    --primary-metallic: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --silver-text: #e2e8f0;
    --muted-metal: #94a3b8;

    --code-bg: rgba(15, 23, 42, 0.8);
}

/* Global Selection Fix for Contrast */
::selection {
    background: var(--primary-metallic);
    color: #ffffff;
}

/* Inverted selection for code and input fields for maximum clarity */
code::selection,
textarea::selection,
input::selection {
    background: #ffffff;
    color: #0f172a;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--silver-text);
    margin: 0;
    min-height: 100vh;
}

header {
    padding: 3rem 1rem;
    text-align: center;
    background: rgba(15, 23, 42, 0.3);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur);
}

header h1 {
    font-size: 2.5rem;
    margin: 0;
    letter-spacing: -1px;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

/* Glass Panel Style */
.panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    margin-bottom: 24px;
}

.config-panel {
    border-left: 4px solid var(--primary-metallic);
}

/* --- API Configuration Layout --- */
.api-config-area {
    display: flex !important;
    flex-direction: row !important;
    gap: 12px;
    align-items: center;
    margin-top: 15px;
    width: 100%;
}

.input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
}

/* Global Input Styles */
label {
    display: block;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 12px;
    margin-bottom: 8px;
    color: var(--muted-metal);
}

textarea,
select,
#apiKeyInput {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 12px;
    color: white;
    font-family: 'Fira Code', monospace;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

#apiKeyInput {
    height: 48px;
    padding-right: 45px;
}

/* Dropdown Arrow Fix */
select {
    appearance: none;
    padding-right: 36px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 15px) center;
    cursor: pointer;
}

/* Password Toggle Icon */
#togglePassword {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--muted-metal);
    background: none;
    border: none;
    z-index: 10;
}

textarea {
    min-height: 125px;
    line-height: 1.5;
    resize: vertical;
    margin-bottom: 16px;
}

textarea:focus,
select:focus,
#apiKeyInput:focus {
    outline: none;
    border-color: var(--primary-metallic);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* --- Unified Metallic Buttons --- */
.primary-btn,
.secondary-btn,
.save-btn {
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-transform: uppercase;
    letter-spacing: 1px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

.primary-btn,
.secondary-btn {
    width: 100%;
    padding: 16px;
}

/* Primary Button (Analyze & Heal) */
.primary-btn {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    margin-top: 20px;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
    filter: brightness(1.1);
}

/* Secondary Button (Clear Diagnostic Data) */
.secondary-btn {
    margin-top: 16px;
    background: linear-gradient(180deg, #475569 0%, #1e293b 100%);
    color: var(--silver-text);
}

.secondary-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, #64748b 0%, #334155 100%);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Save Key Button */
.save-btn {
    width: auto !important;
    min-width: 140px;
    height: 48px;
    padding: 0 24px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #475569 0%, #1e293b 100%);
    color: var(--silver-text);
}

.save-btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(180deg, #3b82f6 0%, #1e293b 100%);
    border-color: var(--primary-metallic);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

/* Button Active State (Click Feel) */
.primary-btn:active,
.secondary-btn:active,
.save-btn:active {
    transform: translateY(0);
    filter: brightness(0.9);
}

/* --- Loading Spinner Styles --- */
.spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary-metallic);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 15px var(--primary-glow);
    margin-bottom: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#loading p {
    color: var(--muted-metal);
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.9rem;
    margin: 0;
}

/* --- Informative Placeholder Styles --- */
.placeholder-info {
    padding: 24px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px dashed var(--glass-border);
}

.info-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.info-header h4 {
    margin: 0;
    color: var(--primary-metallic);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 1rem;
}

.info-icon {
    font-size: 1.5rem;
}

.info-list {
    margin: 16px 0;
    padding-left: 0;
    list-style: none;
}

.info-list li {
    font-size: 0.9rem;
    color: var(--muted-metal);
    margin-bottom: 12px;
    padding-left: 24px;
    position: relative;
    line-height: 1.4;
}

.info-list li::before {
    content: "⚡";
    position: absolute;
    left: 0;
    color: var(--primary-metallic);
}

.info-tip {
    margin-top: 20px;
    padding: 12px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--silver-text);
    border-left: 3px solid var(--primary-metallic);
}

/* --- Layout & Results --- */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
}

.result-block h4 {
    color: var(--muted-metal);
    font-size: 0.8rem;
    margin-top: 24px;
    margin-bottom: 10px;
    text-transform: uppercase;
}

code {
    background: var(--code-bg);
    color: #38bdf8;
    padding: 20px;
    border-radius: 12px;
    display: block;
    border: 1px solid var(--glass-border);
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-x: auto;
}

.link-btn {
    background: none;
    border: none;
    color: var(--primary-metallic);
    text-decoration: underline;
    cursor: pointer;
    display: block;
    width: 100%;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.link-btn:hover {
    color: #ffffff;
    text-shadow: 0 0 8px var(--primary-glow);
    text-decoration: none;
    transform: scale(1.02);
}

.hidden {
    display: none !important;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .api-config-area {
        flex-direction: column !important;
        align-items: stretch;
    }

    .save-btn {
        width: 100% !important;
        margin-top: 12px !important;
    }
}

/* Custom Metallic Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #475569 0%, #1e293b 100%);
    border-radius: 10px;
}

/* --- Footer Styles --- */
.site-footer {
    margin-top: 40px;
    padding: 20px;
    border-top: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: var(--glass-blur);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--muted-metal);
    font-size: 0.9rem;
}

.site-footer a {
    color: var(--primary-metallic);
    text-decoration: none;
    transition: all 0.3s ease;
}

.site-footer a:hover {
    color: #ffffff;
    text-shadow: 0 0 8px var(--primary-glow);
}

/* Mobile Footer Responsiveness */
@media (max-width: 600px) {
    .site-footer {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 25px 15px;
    }
}

/* --- High-Contrast Link Styles --- */
a {
    color: #60a5fa;
    /* Brighter, high-contrast blue for dark themes */
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
    border-bottom: 1px solid transparent;
}

a:hover {
    color: #93c5fd;
    /* Lighter blue on hover */
    border-bottom-color: #93c5fd;
    text-shadow: 0 0 10px rgba(147, 197, 253, 0.5);
}

a:active {
    color: #ffffff;
    filter: brightness(1.2);
}

/* Specific Footer Link styling */
.site-footer a {
    color: #60a5fa;
    font-size: 0.9rem;
}

/* Step 1 Link specifically for the onboarding area */
.info-list a {
    padding: 0 2px;
    border-radius: 2px;
}

/* --- Header & Logo Styles --- */
.site-header {
    padding: 40px 20px;
    text-align: center;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.5) 0%, transparent 100%);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.header-icon {
    width: 60px;
    height: 60px;
    object-fit: contain;
    filter: drop-shadow(0 0 12px var(--primary-glow));
    /* Adds a metallic glow to your icon */
}

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

.header-text h1 {
    margin: 0;
    font-size: 2.5rem;
    background: linear-gradient(90deg, #ffffff, var(--primary-metallic));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-text p {
    margin: 5px 0 0 0;
    color: var(--muted-metal);
    font-size: 1.1rem;
}

/* Mobile Header Adjustment */
@media (max-width: 600px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .header-text {
        text-align: center;
    }

    .header-text h1 {
        font-size: 1.8rem;
    }
}