/* === Base Styles === */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    margin: 20px;
    background-color: #e8ecef;
    color: #333;
    line-height: 1.5;
}

/* === Layout === */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

/* === Card Layout === */
.card {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 25px;
    overflow: hidden;
}

.card-header {
    background: linear-gradient(135deg, #0F4761 0%, #1a5f7f 100%);
    color: #FFFFFF;
    padding: 18px 25px;
    font-weight: 600;
    font-size: 1.1em;
    border-bottom: 3px solid #0A3347;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2,
.card-header h3 {
    margin: 0;
    color: #FFFFFF;
    font-size: 1.1em;
    border: none;
    padding: 0;
}

.card-body {
    padding: 25px;
}

.card-body > *:first-child {
    margin-top: 0;
}

.card-body > *:last-child {
    margin-bottom: 0;
}

/* === Language Switcher / Top Bar === */
.top-bar {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 15px 25px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar h1 {
    margin: 0;
    font-size: 1.5em;
    color: #0F4761;
    text-align: left;
}

.language-switcher {
    display: flex;
    align-items: center;
    gap: 10px;
}
.language-switcher button {
    background-color: #7f8c8d;
    font-size: 0.9em;
    padding: 8px 12px;
    margin: 0;
}
.language-switcher button:hover {
    background-color: #6c7a7d;
}
.language-switcher a:first-child button {
    background-color: #e67e22;
}
.language-switcher a:first-child button:hover {
    background-color: #d35400;
}
.language-switcher .current-lang {
    font-weight: bold;
    color: #0F4761;
}

/* === Typography === */
h1 {
    color: #2c3e50;
    margin-bottom: 1em;
}
h2 {
    color: #34495e;
    margin-top: 1.5em;
    margin-bottom: 1em;
}
h3 {
    color: #2c3e50;
    margin-top: 1.2em;
    margin-bottom: 0.8em;
}

/* === Forms === */
label {
    display: block;
    margin-top: 12px;
    margin-bottom: 6px;
    font-weight: 600;
    color: #555;
}
input[type="text"],
input[type="file"],
textarea {
    width: 100%;
    padding: 12px;
    margin-top: 5px;
    border: 1px solid #bdc3c7;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 1em;
    transition: border-color 0.2s ease-in-out;
}
input[type="text"]:focus,
input[type="file"]:focus,
textarea:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}
textarea {
    min-height: 90px;
    resize: vertical;
}

/* === Buttons === */
.button-group {
    margin-top: 20px;
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
button {
    background-color: #3498db;
    color: white;
    padding: 12px 18px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: background-color 0.2s ease-in-out;
}
button:hover {
    background-color: #2980b9;
}
button[type="button"] {
    background-color: #27ae60;
    transition: background-color 0.2s ease-in-out;
}
button[type="button"]:hover {
    background-color: #229954;
}

/* === Output Area === */
.output-area {
    margin-top: 20px;
    padding: 20px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    min-height: 120px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    line-height: 1.6;
}
.output-area h1,
.output-area h2,
.output-area h3,
.output-area h4 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    color: #2c3e50;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.output-area p {
    margin-top: 0;
    margin-bottom: 0.8em;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.output-area ul,
.output-area ol {
    margin-bottom: 0.8em;
    padding-left: 25px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.output-area li {
    margin-bottom: 0.3em;
}
.output-area pre {
    background-color: #2d2d2d;
    color: #f0f2f5;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    white-space: pre;
    margin-bottom: 1em;
}
.output-area code {
    background-color: #ecf0f1;
    color: #c0392b;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}
.output-area pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
    font-size: inherit;
    white-space: pre;
}
.output-area table {
    border-collapse: collapse;
    width: auto;
    margin-bottom: 1em;
    border: 1px solid #dfe6e9;
}
.output-area th,
.output-area td {
    border: 1px solid #dfe6e9;
    padding: 8px 12px;
    text-align: left;
}
.output-area th {
    background-color: #f0f4f7;
    font-weight: 600;
}
.output-area blockquote {
    border-left: 4px solid #bdc3c7;
    padding-left: 1em;
    margin-left: 0;
    color: #7f8c8d;
    font-style: italic;
}

/* === Status & Error Messages === */
.error {
    color: #e74c3c;
    font-weight: bold;
    background-color: #fadbd8;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #f1c6c2;
}
.info {
    font-size: 0.9em;
    color: #7f8c8d;
    margin-bottom: 1em;
}

.app-subtitle {
    text-align: center;
    color: #7f8c8d;
    margin-bottom: 1.5em;
    font-size: 1em;
}

/* === htmx Loading Indicators === */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline-block;
}
.htmx-request.htmx-indicator {
    display: inline-block;
}
/* === Spinner (htmx polling) === */
.spinner-container {
    text-align: center;
    padding: 40px 20px;
}
.spinner-container p {
    margin-top: 15px;
    color: #2980b9;
    font-style: italic;
}
.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #ecf0f1;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.status-message {
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 5px;
    border: 1px solid;
    font-weight: 500;
}
.status-message.success {
    border-color: #abebc6;
    background-color: #eafaf1;
    color: #1e8449;
}
.status-message.error {
    border-color: #f1c6c2;
    background-color: #fadbd8;
    color: #e74c3c;
}

/* === Response Header === */
.response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.response-header h2 {
    margin: 0;
}

/* === Clipboard === */
.clipboard-success {
    background-color: #d4edda !important;
    border-color: #c3e6cb !important;
    color: #155724 !important;
}

/* === Instructions Box === */
.instructions-content {
    font-size: 0.9em;
    line-height: 1.6;
    color: #2c3e50;
}
.instructions-content p {
    margin-bottom: 8px;
}
.instructions-content p:last-child {
    margin-bottom: 0;
}
.instructions-content .step-success {
    color: #28a745;
    font-weight: 600;
}
.instructions-content .step-danger {
    color: #dc3545;
    font-weight: 600;
}
.instructions-content .step-warning {
    color: #e67e22;
    font-weight: 600;
}
.instructions-content .step-muted {
    color: #6c757d;
    font-size: 0.85em;
    font-style: italic;
}

/* === Collapsible Toggle === */
.collapse-toggle {
    background: none;
    border: none;
    color: #FFFFFF;
    cursor: pointer;
    padding: 5px 10px;
    font-size: 1.2em;
    transition: transform 0.3s ease;
}

.collapse-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.collapse-toggle.collapsed {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.collapsible-content.hidden {
    max-height: 0;
}

/* === Login Page === */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
}
.login-container {
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 320px;
}
.login-container h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 25px;
}
.form-group {
    margin-bottom: 20px;
}
input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #bdc3c7;
    border-radius: 5px;
    box-sizing: border-box;
}
.flash-error {
    padding: 10px;
    background-color: #fadbd8;
    color: #e74c3c;
    border: 1px solid #f1c6c2;
    border-radius: 5px;
    margin-bottom: 15px;
    text-align: center;
}
.login-container button {
    width: 100%;
}

/* === Batch Upload Styles === */
.progress-bar {
    width: 100%;
    height: 25px;
    background-color: #ecf0f1;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 15px;
    border: 1px solid #bdc3c7;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2980b9);
    transition: width 0.5s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.85em;
}
.batch-items {
    list-style: none;
    padding: 0;
    margin: 15px 0;
}
.batch-item {
    padding: 10px 15px;
    margin-bottom: 8px;
    border-radius: 5px;
    border-left: 4px solid;
    background-color: #f8f9fa;
    font-size: 0.95em;
}
.batch-item-pending {
    border-left-color: #95a5a6;
    background-color: #f8f9fa;
}
.batch-item-processing {
    border-left-color: #3498db;
    background-color: #e3f2fd;
    font-weight: 500;
}
.batch-item-completed {
    border-left-color: #27ae60;
    background-color: #eafaf1;
}
.batch-item-failed {
    border-left-color: #e74c3c;
    background-color: #fadbd8;
}
.batch-item .error {
    display: block;
    margin-top: 5px;
    font-size: 0.85em;
    color: #c0392b;
}
.download-btn {
    display: inline-block;
    background-color: #27ae60;
    color: white;
    padding: 12px 20px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s ease-in-out;
    margin-top: 15px;
}
.download-btn:hover {
    background-color: #229954;
}

/* === Markdown Editor Card === */
#markdown-editor-section {
    margin-top: 25px;
}
#markdown-editor-section .card-header {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    border-bottom-color: #7d3c98;
}
#markdown-editor-section textarea {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    min-height: 300px;
    background-color: white;
}
#markdown-editor-section .info {
    text-align: left;
    margin-bottom: 15px;
    font-size: 0.9em;
    color: #666;
}

/* === Feedback Card === */
#feedback-section {
    margin-top: 25px;
}
#feedback-section .card-header {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    border-bottom-color: #d68910;
}
#feedback-section textarea {
    min-height: 100px;
}
#feedback-section .info {
    text-align: left;
    margin-bottom: 15px;
    font-size: 0.9em;
    color: #666;
}
