/* Global Styles */
:root {
    --primary-color: #0077b5;
    --secondary-color: #00a0dc;
    --background-color: #f3f2ef;
    --text-color: #333;
    --error-color: #d93025;
    --success-color: #0f9d58;
    --border-radius: 8px;
    --box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
    position: relative;
}

/* Matrix Container Styles */
.matrix-container {
    background: white;
    padding: 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    position: relative;
    z-index: 1;
}

.matrix-title {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 2.5rem;
    font-weight: 600;
}

.intro-text {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-color);
    font-size: 1.1rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Form Styles */
.matrix-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.matrix-label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-color);
    font-size: 1rem;
}

.matrix-input {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid #e1e1e1;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: white;
}

.matrix-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 119, 181, 0.1);
}

/* Radio Button Styles */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border: 2px solid #e1e1e1;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    cursor: pointer;
    background: white;
}

.radio-option:hover {
    border-color: var(--primary-color);
    background: #f8f9fa;
}

.radio-option:has(.radio-input:checked) {
    border-color: var(--primary-color);
    background: #f0f8ff;
    box-shadow: 0 0 0 3px rgba(0, 119, 181, 0.1);
}

.radio-input {
    margin: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.radio-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    cursor: pointer;
    flex: 1;
}

.radio-label strong {
    color: var(--text-color);
    font-size: 1rem;
}

.radio-description {
    color: #666;
    font-size: 0.875rem;
    line-height: 1.4;
}

/* Upload Area Styles */
.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.upload-area {
    position: relative;
    border: 2px dashed #ddd;
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    background: #fafafa;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #f5f5f5;
}

/* Button Styles */
.matrix-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.875rem 1.75rem;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.matrix-button:hover {
    background-color: var(--secondary-color);
    transform: translateY(-1px);
}

.matrix-button:active {
    transform: translateY(0);
}

.button-container {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.submit-button {
    min-width: 200px;
    font-size: 1.1rem;
    padding: 1rem 2rem;
}

.error-message {
    background-color: #f8d7da;
    color: var(--error-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    border: 1px solid #f5c6cb;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
    word-wrap: break-word;
}

.stats-message {
    background-color: #d4edda;
    color: var(--success-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    border: 1px solid #c3e6cb;
}

.help-text {
    color: #666;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.file-name {
    margin-top: 0.5rem;
    font-weight: 500;
    color: var(--primary-color);
}

/* Status Container and Progress Tracking */
.status-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
}

.status-header {
    margin-bottom: 1rem;
}

.status-header h3 {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #22c55e);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-text {
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
}

.status-log {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.4;
}

.log-entry {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    word-wrap: break-word;
    border-left: 4px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
}

.log-entry:last-child {
    margin-bottom: 0;
    animation: slideIn 0.3s ease-out;
}

.log-timestamp {
    color: #9ca3af;
    font-size: 0.8rem;
    font-family: 'Courier New', monospace;
    white-space: nowrap;
    min-width: 80px;
}

.log-message {
    flex: 1;
    line-height: 1.4;
}

.log-info {
    color: #e0e7ff;
    border-left-color: #3b82f6;
}

.log-success {
    color: #bbf7d0;
    border-left-color: #10b981;
}

.log-error {
    color: #fecaca;
    border-left-color: #ef4444;
}

.log-warning {
    color: #fed7aa;
    border-left-color: #f59e0b;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Configuration Table Styles */
.config-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.config-container h3 {
    margin: 0 0 1rem 0;
    color: #1e293b;
    font-size: 1.125rem;
    font-weight: 600;
}

.config-table-wrapper {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.config-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.config-table th,
.config-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.config-table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #374151;
}

.config-table td {
    color: #4b5563;
}

.config-table tr:last-child td {
    border-bottom: none;
}

.config-table tr:hover {
    background-color: #f9fafb;
}

.status-success {
    color: #059669;
    font-weight: 600;
}

.status-warning {
    color: #d97706;
    font-weight: 600;
}

.status-error {
    color: #dc2626;
    font-weight: 600;
}

.status-loading {
    color: #6b7280;
    font-style: italic;
}

/* API Logs Summary */
.api-logs-summary {
  margin: 2rem 0;
  padding: 1.5rem;
  background: #f8f9fa;
  border-radius: var(--border-radius);
  border: 1px solid #e9ecef;
}

.api-logs-summary h4 {
  margin: 0 0 1rem 0;
  color: var(--primary-color);
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.api-logs-summary h4::before {
  content: "📊";
  font-size: 1.2rem;
}

.api-logs-list {
  max-height: 400px;
  overflow-y: auto;
  background: white;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  padding: 0.5rem;
}

.api-log-entry {
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.2rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.api-log-entry:last-child {
  margin-bottom: 0;
}

.api-log-entry.info {
  background-color: #e3f2fd;
  border-left-color: #2196f3;
  color: #1565c0;
}

.api-log-entry.success {
  background-color: #e8f5e8;
  border-left-color: #4caf50;
  color: #2e7d32;
}

.api-log-entry.error {
  background-color: #ffebee;
  border-left-color: #f44336;
  color: #c62828;
}

.api-log-entry.warning {
  background-color: #fff3e0;
  border-left-color: #ff9800;
  color: #ef6c00;
}

.api-log-entry.api_call_start {
  background-color: #f3e5f5;
  border-left-color: #9c27b0;
  color: #6a1b9a;
}

.api-log-entry.api_call_result {
  background-color: #e0f2f1;
  border-left-color: #009688;
  color: #00695c;
}

.api-log-entry::before {
  font-size: 0.7rem;
  opacity: 0.8;
}

.api-log-entry.info::before {
  content: "ℹ️";
}

.api-log-entry.success::before {
  content: "✅";
}

.api-log-entry.error::before {
  content: "❌";
}

.api-log-entry.warning::before {
  content: "⚠️";
}

.api-log-entry.api_call_start::before {
  content: "🚀";
}

.api-log-entry.api_call_result::before {
  content: "📡";
}

.log-message {
  flex: 1;
  word-break: break-word;
}

/* Table Styles */
.matrix-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
}

.matrix-table th,
.matrix-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e1e1e1;
}

.matrix-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--text-color);
}

.matrix-table tr:hover {
    background-color: #f8f9fa;
}

.table-responsive {
    overflow-x: auto;
    border-radius: var(--border-radius);
}

/* Results Container */
.results-container {
    margin-top: 2rem;
}

.results-container h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.75rem;
}

/* Upload Button */
.upload-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.upload-button:hover {
    background-color: var(--secondary-color);
    transform: translateY(-1px);
}

.upload-button:active {
    transform: translateY(0);
}

/* Canvas and Spinner */
#matrix-canvas {
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    margin-top: 1rem;
    display: block;
    max-width: 100%;
    height: auto;
}

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

.spinner {
    animation: spin 1s linear infinite;
}

.matrix-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

.matrix-button:disabled:hover {
    background-color: #ccc;
    transform: none;
}

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

/* Download Info */
.download-info {
    background-color: #e3f2fd;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-top: 1rem;
    border: 1px solid #bbdefb;
}

.download-info p {
    margin: 0;
    color: #1976d2;
}

.download-info strong {
    color: #1565c0;
}

/* Stats Summary */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-item strong {
    display: block;
    color: var(--primary-color);
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

/* Download Options */
.download-options {
    margin: 2rem 0;
}

.download-options h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
}

.download-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.download-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
}

.download-button.identified {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.download-button.identified:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.download-button.all {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}

.download-button.all:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.download-button svg {
    flex-shrink: 0;
}

/* Preview Section */
.preview-section {
    margin: 2rem 0;
}

.preview-section h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
}

/* Responsive Design */
@media (max-width: 600px) {
    .container {
        margin: 1rem auto;
        padding: 0 0.5rem;
    }
    
    .matrix-container {
        padding: 1.5rem;
    }
    
    .matrix-title {
        font-size: 2rem;
    }
    
    .radio-option {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .radio-label strong {
        font-size: 0.9rem;
    }
    
    .radio-description {
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    .status-container {
        margin-top: 1.5rem;
        padding: 1rem;
    }
    
    .status-log {
        max-height: 150px;
        font-size: 0.8rem;
    }
    
    .api-logs-summary {
        margin: 1.5rem 0;
        padding: 1rem;
    }
    
    .api-logs-list {
        max-height: 200px;
    }
    
    .download-buttons {
        flex-direction: column;
    }
    
    .download-button {
        justify-content: center;
    }
    
    .stats-summary {
        grid-template-columns: 1fr;
    }
}

/* Non-identified names section */
.non-identified-section {
  margin: 2rem 0;
  padding: 1.5rem;
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  border-radius: var(--border-radius);
}

.non-identified-section h3 {
  color: #856404;
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.non-identified-section p {
  color: #856404;
  margin: 0 0 1rem 0;
  font-size: 0.95rem;
}

.textarea-container {
  position: relative;
}

.non-identified-textarea {
  width: 100%;
  padding: 1rem;
  border: 2px solid #ffeaa7;
  border-radius: var(--border-radius);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.4;
  background: white;
  resize: vertical;
  min-height: 120px;
}

.non-identified-textarea:focus {
  outline: none;
  border-color: #f39c12;
  box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.1);
}

.textarea-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.copy-button,
.select-all-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid #f39c12;
  border-radius: var(--border-radius);
  background: white;
  color: #856404;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-button:hover,
.select-all-button:hover {
  background: #f39c12;
  color: white;
}

.copy-button:active,
.select-all-button:active {
  transform: translateY(1px);
}

.copy-button svg,
.select-all-button svg {
  width: 14px;
  height: 14px;
}

/* Responsive adjustments for non-identified section */
@media (max-width: 768px) {
  .non-identified-section {
    padding: 1rem;
  }
  
  .textarea-actions {
    flex-direction: column;
  }
  
  .copy-button,
  .select-all-button {
    justify-content: center;
  }
}
