/* General Styles & Reset */
:root {
    --primary-color: #4a46e8;
    --light-primary-color: #eef2ff;
    --secondary-color: #f8f9fa;
    --font-color: #333;
    --border-color: #e5e7eb;
    --sidebar-bg: #ffffff;
    --main-bg: #f9fafb;
    --green-color: #10b981;
    --red-color: #ef4444;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--main-bg);
    color: var(--font-color);
    font-size: 14px;
}

a {
    text-decoration: none;
    color: inherit;
}

/* App Layout */
.app-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Sidebar */
.sidebar-header {
    margin-bottom: 2rem;
}
.sidebar-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    color: #111827;
}
.sidebar-header span {
    font-size: 0.8rem;
    color: #6b7280;
}

.sidebar-menu {
    list-style: none;
    flex-grow: 1;
}
.sidebar-menu li {
    margin-bottom: 0.5rem;
}
.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    color: #374151;
}
.sidebar-menu li a:hover {
    background-color: var(--light-primary-color);
    color: var(--primary-color);
}
.sidebar-menu li.active a {
    background-color: var(--light-primary-color);
    color: var(--primary-color);
}
.sidebar-menu li i {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
}
.api-status-box {
    background-color: #fffbeB;
    border: 1px solid #fef3c7;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
}
.api-status-box .status-dot-red {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--red-color);
    border-radius: 50%;
    margin-right: 0.5rem;
}
.api-status-box a {
    display: block;
    margin-top: 0.25rem;
    color: #92400e;
    font-weight: 500;
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
}
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.queue-status {
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.start-button {
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.start-button:hover {
    background-color: #4338ca;
}

/* Page Content */
.page-content {
    padding: 2rem;
    overflow-y: auto;
    flex-grow: 1;
}

.page-header {
    margin-bottom: 2rem;
}
.page-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #111827;
}
.page-header p {
    color: #6b7280;
    margin-top: 0.25rem;
}

.card {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 2rem;
}
.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.card-header h4 {
    font-size: 1rem;
    font-weight: 600;
}
.card-header span {
    font-size: 0.8rem;
    color: #6b7280;
}
.card-body {
    padding: 1.5rem;
}

.upload-view-container {
    display: flex;
    gap: 2rem;
}
.upload-main-column {
    flex: 2;
}
.upload-sidebar-column {
    flex: 1;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    background-color: #f9fafb;
}
.drop-zone i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}
.drop-zone p {
    font-size: 1rem;
    color: #374151;
}
.drop-zone span {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 1rem;
    display: block;
}
.choose-file-button {
    background-color: #ffffff;
    color: #374151;
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
}

/* Recent Uploads Table */
.recent-uploads-table {
    width: 100%;
    border-collapse: collapse;
}
.recent-uploads-table th, .recent-uploads-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}
.recent-uploads-table th {
    color: #6b7280;
    font-weight: 500;
}
.recent-uploads-table td i {
    color: var(--green-color);
    margin-right: 0.5rem;
}
.status-mapped {
    background-color: #e0f2f1;
    color: #00796b;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.8rem;
}
.action-btn {
    color: #6b7280;
    font-weight: 500;
    margin-right: 1rem;
}
.action-btn.delete {
    color: var(--red-color);
}

/* Status Badges */
.status {
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.8rem;
}
.status-published {
    background-color: #d1fae5;
    color: #065f46;
}
.status-pending {
    background-color: #fef3c7;
    color: #92400e;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    resize: vertical;
}
.save-template-button {
    background-color: var(--green-color);
    color: #ffffff;
    width: 100%;
    padding: 0.8rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
}
.save-template-button:hover {
    background-color: #0d9488;
}

/* Mapping Page */
.mapping-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    background-color: #f9fafb;
}

/* Alert Boxes */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert-danger {
    color: #991b1b;
    background-color: #fee2e2;
    border-color: #fecaca;
}
.alert-warning {
    color: #92400e;
    background-color: #fffbeb;
    border-color: #fef3c7;
}
.alert-success {
    color: #065f46;
    background-color: #d1fae5;
    border-color: #a7f3d0;
}

/* Scheduling Page */
.code-block, .log-box {
    background-color: #f3f4f6;
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 6px;
    font-family: "Courier New", Courier, monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.log-box {
    max-height: 400px;
    overflow-y: auto;
    background-color: #1f2937;
    color: #e5e7eb;
}

/* Preview Page */
.preview-container {
    display: flex;
    gap: 2rem;
    height: calc(100vh - 200px); /* Adjust based on your header/footer height */
}
.editor-column, .preview-column {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.editor-textarea {
    flex-grow: 1;
    resize: none;
    font-family: 'Courier New', Courier, monospace;
}
.preview-box {
    flex-grow: 1;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.5rem;
    overflow-y: auto;
}
.preview-image {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin-bottom: 1.5rem;
}
.article-content h1, .article-content h2, .article-content h3 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}
.article-content p {
    margin-bottom: 1em;
    line-height: 1.6;
}
.form-actions {
    margin-top: 1rem;
    display: flex;
    gap: 1rem;
}
.button {
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.button-primary {
    background-color: var(--primary-color);
    color: #ffffff;
}
.button-primary:hover {
    background-color: #4338ca;
}
.button-secondary {
    background-color: #e5e7eb;
    color: #374151;
}
.button-secondary:hover {
    background-color: #d1d5db;
}
.button-danger {
     background-color: var(--red-color);
    color: #ffffff;
}
.button-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}
.status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}
.status-processed {
    background-color: #d1fae5;
    color: #065f46;
}
.status-queued {
    background-color: #fef3c7;
    color: #92400e;
}

/* Collapsible Sidebar */
.sidebar {
    transition: width 0.3s ease;
    position: relative; /* For positioning the toggle button */
}

.sidebar-header h3 span, .sidebar-header > span {
    transition: opacity 0.2s ease;
    opacity: 1;
}

.sidebar-collapsed .sidebar {
    width: 88px;
    padding: 1.5rem 0.5rem;
}

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

.sidebar-collapsed .sidebar-header h3 span,
.sidebar-collapsed .sidebar-header > span,
.sidebar-collapsed .sidebar-menu li a span,
.sidebar-collapsed .api-status-box span,
.sidebar-collapsed .api-status-box a {
    display: none;
    opacity: 0;
}

.sidebar-collapsed .sidebar-menu li a {
    justify-content: center;
}

.sidebar-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: #6b7280;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: -12px;
    top: 2rem;
    background-color: white;
    transition: transform 0.3s ease;
}

.sidebar-collapsed .sidebar-toggle-btn {
    transform: rotate(180deg);
}

.main-content {
    transition: margin-left 0.3s ease;
}
