/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    line-height: 1.6;
    color: #3b496e;
    background-color: #f8f9fc;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Screen Management */
.screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Login/Auth Screens */
.login-container {
    background: white;
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(59, 73, 110, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.icon {
    width: 48px;
    height: 48px;
    background: #3b496e;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 24px;
    color: white;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #3b496e;
}

.login-header p {
    color: #6b7280;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: #3b496e;
}

input[type="text"], 
input[type="password"], 
textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #80b4e1;
    border-radius: 0.375rem;
    font-size: 1rem;
    transition: border-color 0.15s ease-in-out;
}

input:focus, textarea:focus {
    outline: none;
    border-color: #3b496e;
    box-shadow: 0 0 0 3px rgba(59, 73, 110, 0.1);
}

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

.questions-input {
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    gap: 0.5rem;
}

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

.btn-primary {
    background: #3b496e;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2d3851;
}

.btn-success {
    background: #80b4e1;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #6ba3d6;
}

.btn-gradient {
    background: linear-gradient(to right, #80b4e1, #3b496e);
    color: white;
}

.btn-gradient:hover:not(:disabled) {
    background: linear-gradient(to right, #6ba3d6, #2d3851);
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.btn-large {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.link-btn {
    background: none;
    border: none;
    color: #80b4e1;
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: underline;
}

.link-btn:hover {
    color: #3b496e;
}

/* Main App Layout */
#mainApp {
    align-items: flex-start;
    padding-top: 0;
}

.app-header {
    margin-bottom: 2rem;
}

.app-header h1 {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #3b496e;
}

.app-header p {
    color: #6b7280;
    margin-bottom: 1rem;
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: #6b7280;
}

/* Top Section */
.top-section {
    margin-bottom: 1.5rem;
}

.compact-card {
    background: white;
    padding: 1rem;
    border-radius: 0.375rem;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: end;
    gap: 1rem;
}

.compact-card .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* API Key Input Styling */
#apiKeyInput {
    display: none;
    font-family: 'Courier New', monospace;
}

#saveApiKeyBtn {
    display: none;
}

/* Layout Grid */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* Left Column Styles */
.left-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Right Column Styles */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Card Styles */
.card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(59, 73, 110, 0.1);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #3b496e;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h2 {
    margin-bottom: 0;
}

/* Output Box */
.output-box {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    padding: 1rem;
    min-height: 400px;
    white-space: pre-wrap;
    font-family: inherit;
    line-height: 1.6;
    color: #6b7280;
    font-style: italic;
}

.output-box:not(:empty) {
    color: #3b496e;
    font-style: normal;
}

/* Help Text */
.help-text {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(59, 73, 110, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 0.5rem;
    text-align: center;
    box-shadow: 0 10px 25px rgba(59, 73, 110, 0.2);
}

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .app-header h1 {
        font-size: 1.5rem;
    }
    
    .compact-card {
        flex-direction: column;
        align-items: stretch;
    }
    
    .compact-card .form-group {
        margin-bottom: 1rem;
    }
    
    #saveApiKeyBtn {
        align-self: flex-start;
    }
}