:root {
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --primary-color: #000000;
    --primary-hover: #333333;
    --error-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #dc2626;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
}

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

/* --- Header --- */

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

h2 {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

/* --- Buttons --- */

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.15s, opacity 0.15s;
    text-decoration: none;
}

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

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--bg-color);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
    border: none;
}

.btn-danger:hover:not(:disabled) {
    background-color: #b91c1c;
}

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

/* --- Alerts --- */

.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
}

.alert-error {
    background-color: #fef2f2;
    color: var(--error-color);
    border: 1px solid #fecaca;
}

/* --- Login --- */

.login-container {
    max-width: 400px;
    margin: 4rem auto;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
}

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

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.875rem;
}

textarea {
    resize: vertical;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* --- Dashboard --- */

.dashboard-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.compose-section {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.char-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.char-count.over-limit {
    color: var(--error-color);
    font-weight: 600;
}

/* --- Queue Sections --- */

.queue-sections {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.section-header-row h2 {
    margin-bottom: 0;
}

.filters {
    display: flex;
    gap: 0.5rem;
}

.filter-input {
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--card-bg);
}

.filter-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.count-badge {
    font-size: 0.75rem;
    font-weight: 600;
    background-color: var(--bg-color);
    color: var(--text-secondary);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    vertical-align: middle;
}

.empty-state {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 1.5rem;
}

/* --- Tweet Items --- */

.tweet-list {
    list-style: none;
}

.tweet-item {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tweet-item.failed {
    border-color: #fecaca;
    background-color: #fef2f2;
}

.tweet-content {
    white-space: pre-wrap;
    word-break: break-word;
    unicode-bidi: plaintext;
    direction: auto;
}

.tweet-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
}

.tweet-error {
    font-size: 0.75rem;
    color: var(--error-color);
    margin-top: 0.25rem;
}

.tweet-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.125rem 0.25rem;
    border-radius: 4px;
    transition: color 0.15s, background-color 0.15s;
}

.btn-icon:hover {
    color: var(--primary-color);
    background-color: var(--bg-color);
}

.btn-icon.btn-delete:hover {
    color: var(--error-color);
    background-color: #fef2f2;
}

.btn-icon.btn-retry:hover {
    color: var(--success-color);
    background-color: #d1fae5;
}

/* --- Bot Status --- */

.bot-status-section {
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.bot-status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bot-status-header h2 {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
}

.badge-unknown {
    background-color: #f3f4f6;
    color: #4b5563;
}

.badge-valid {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-invalid, .badge-error {
    background-color: #fee2e2;
    color: #991b1b;
}

.text-sm {
    font-size: 0.875rem;
}

.text-secondary {
    color: var(--text-secondary);
}

/* --- Modals --- */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    margin: 1rem;
    animation: slideUp 0.2s ease;
}

.confirm-box {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.confirm-box p {
    font-size: 1rem;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.time-window-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

/* --- Toast Notifications --- */

#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: white;
    min-width: 260px;
    max-width: 380px;
    pointer-events: auto;
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 3.7s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast-success {
    background-color: var(--success-color);
}

.toast-error {
    background-color: var(--error-color);
}

.toast-warning {
    background-color: var(--warning-color);
    color: #111827;
}

/* --- Animations --- */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* --- Responsive --- */

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }
}
