/* Knitting Pattern Converter - Main Styles */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    z-index: 100;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

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

.content {
    padding: 40px;
}

/* Ollama Status Banner */
.ollama-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.95em;
}

.ollama-status span:first-child {
    font-size: 1.2em;
    font-weight: bold;
}

/* Ollama Settings */
.ollama-settings {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ollama-settings .form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ollama-settings label {
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.ollama-settings input,
.ollama-settings select {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
}

.ollama-settings input:focus,
.ollama-settings select:focus {
    outline: none;
    border-color: #667eea;
}

.ollama-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
}

.ollama-info h4 {
    margin-bottom: 10px;
    color: #333;
}

.ollama-info ol {
    margin-left: 20px;
}

.ollama-info li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.ollama-info code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

/* Upload Section */
.upload-section {
    border: 3px dashed #667eea;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    margin-bottom: 30px;
    background: #f8f9ff;
    transition: all 0.3s ease;
}

.upload-section:hover {
    border-color: #764ba2;
    background: #f0f2ff;
}

.upload-section.dragover {
    background: #e8eaff;
    border-color: #764ba2;
    transform: scale(1.02);
}

.upload-section h2 {
    margin-bottom: 20px;
}

.upload-section p {
    margin-bottom: 20px;
    color: #666;
}

.file-input-wrapper {
    display: inline-block;
    position: relative;
    overflow: hidden;
}

.file-input-wrapper input[type=file] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn:focus {
    outline: 3px solid #764ba2;
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #28a745;
    margin-left: 10px;
}

.btn-secondary:hover {
    box-shadow: 0 10px 20px rgba(40, 167, 69, 0.3);
}

.btn-outline {
    background: transparent;
    border: 2px solid #667eea;
    color: #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
}

.btn-danger {
    background: #dc3545;
}

.btn-danger:hover {
    box-shadow: 0 10px 20px rgba(220, 53, 69, 0.3);
}

/* Text areas */
textarea {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 20px;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Section titles */
.section-title {
    font-size: 1.5em;
    margin-bottom: 15px;
    color: #333;
    display: flex;
    align-items: center;
}

.section-title::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin-right: 15px;
    border-radius: 3px;
}

/* Output section */
.output-section {
    margin-top: 30px;
    display: none;
}

.output-section.active {
    display: block;
}

.preview {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    border: 2px solid #ddd;
    max-height: 400px;
    overflow-y: auto;
}

.preview:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Info box */
.info-box {
    background: #e7f3ff;
    border-left: 4px solid #2196F3;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
}

.info-box h3 {
    color: #2196F3;
    margin-bottom: 10px;
}

/* Button groups */
.button-group {
    margin-top: 20px;
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.button-group .btn {
    margin-left: 0;
}

/* Loading */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.loading.active {
    display: block;
}

.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;
}

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

/* File info */
.file-info {
    margin-top: 15px;
    padding: 10px;
    background: white;
    border-radius: 5px;
    display: none;
}

.file-info.active {
    display: block;
}

.file-info strong {
    color: #667eea;
}

/* Panels (History, Custom Abbreviations, Ollama) */
.panel {
    margin-top: 30px;
    border: 1px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
}

.panel-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.panel-header h2 {
    font-size: 1.2em;
    color: #333;
    margin: 0;
}

.panel-header .toggle-icon {
    font-size: 1.5em;
    color: #666;
    transition: transform 0.3s ease;
}

.panel.collapsed .panel-header .toggle-icon {
    transform: rotate(-90deg);
}

.panel-content {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.panel.collapsed .panel-content {
    display: none;
}

/* History list */
.history-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item-content {
    flex: 1;
}

.history-item-date {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 5px;
}

.history-item-preview {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

.history-item-actions {
    display: flex;
    gap: 8px;
}

.empty-state {
    text-align: center;
    color: #666;
    padding: 20px;
}

/* Custom abbreviation form */
.abbrev-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.abbrev-form input {
    flex: 1;
    min-width: 120px;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
}

.abbrev-form input:focus {
    outline: none;
    border-color: #667eea;
}

/* Abbreviation list */
.abbrev-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.abbrev-tag {
    display: inline-flex;
    align-items: center;
    background: #f0f2ff;
    border: 1px solid #667eea;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.9em;
}

.abbrev-tag-text {
    margin-right: 8px;
}

.abbrev-tag-delete {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
    padding: 0;
}

.abbrev-tag-delete:hover {
    color: #a71d2a;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    background: #333;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.toast.success {
    background: #28a745;
}

.toast.error {
    background: #dc3545;
}

.toast.hiding {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Mode toggle */
.mode-toggle {
    display: flex;
    background: #f0f0f0;
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 20px;
}

.mode-toggle button {
    flex: 1;
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    font-size: 1em;
    transition: all 0.2s ease;
}

.mode-toggle button.active {
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    color: #667eea;
    font-weight: 600;
}

.mode-toggle button:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Footer */
footer {
    border-top: 1px solid #eee;
    margin-top: 30px;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .content {
        padding: 20px;
    }

    .upload-section {
        padding: 20px;
    }

    .button-group {
        flex-direction: column;
    }

    .button-group .btn {
        width: 100%;
    }

    .abbrev-form {
        flex-direction: column;
    }

    .abbrev-form input {
        width: 100%;
    }

    .ollama-status {
        flex-direction: column;
        text-align: center;
    }

    .ollama-status .btn {
        margin-left: 0;
        margin-top: 10px;
    }
}
