/* ==================== VARIABLES ==================== */
:root {
    --tg-theme-bg-color: var(--tg-theme-bg-color, #ffffff);
    --tg-theme-text-color: var(--tg-theme-text-color, #000000);
    --tg-theme-hint-color: var(--tg-theme-hint-color, #999999);
    --tg-theme-link-color: var(--tg-theme-link-color, #2481cc);
    --tg-theme-button-color: var(--tg-theme-button-color, #5288c1);
    --tg-theme-button-text-color: var(--tg-theme-button-text-color, #ffffff);
    --tg-theme-secondary-bg-color: var(--tg-theme-secondary-bg-color, #f0f0f0);

    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --gradient-purple: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-green: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --gradient-blue: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
    --gradient-orange: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    min-height: 100vh;
    padding-bottom: 80px;
}

/* ==================== HEADER ==================== */
.header {
    position: sticky;
    top: 0;
    background: var(--gradient-purple);
    padding: 16px 20px;
    z-index: 100;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 18px;
    font-weight: 600;
}

.header-icon {
    font-size: 24px;
}

/* ==================== TABS ==================== */
.tabs {
    display: flex;
    background: var(--tg-theme-secondary-bg-color);
    padding: 8px;
    gap: 4px;
    position: sticky;
    top: 56px;
    z-index: 99;
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--tg-theme-hint-color);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    background: var(--tg-theme-bg-color);
    color: var(--primary);
    box-shadow: var(--shadow);
}

.tab-icon {
    font-size: 20px;
}

/* ==================== CONTENT ==================== */
.content {
    padding: 16px;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

/* ==================== STATS GRID ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    padding: 16px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
}

.stat-card.gradient-purple { background: var(--gradient-purple); }
.stat-card.gradient-green { background: var(--gradient-green); }
.stat-card.gradient-blue { background: var(--gradient-blue); }
.stat-card.gradient-orange { background: var(--gradient-orange); }

.stat-icon {
    font-size: 28px;
    opacity: 0.9;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
}

.stat-label {
    font-size: 12px;
    opacity: 0.9;
}

/* ==================== CARDS ==================== */
.card {
    background: var(--tg-theme-bg-color);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.card-description {
    font-size: 13px;
    color: var(--tg-theme-hint-color);
    margin-bottom: 12px;
}

/* ==================== ACTIONS GRID ==================== */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    border: none;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:active {
    transform: scale(0.98);
    background: rgba(99, 102, 241, 0.1);
}

.action-icon {
    font-size: 24px;
}

.action-btn span:last-child {
    font-size: 13px;
    color: var(--tg-theme-text-color);
}

/* ==================== POSTS LIST ==================== */
.posts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.post-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.post-item:active {
    background: rgba(99, 102, 241, 0.1);
}

.post-status {
    font-size: 20px;
}

.post-info {
    flex: 1;
    min-width: 0;
}

.post-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.post-meta {
    font-size: 12px;
    color: var(--tg-theme-hint-color);
}

.post-arrow {
    color: var(--tg-theme-hint-color);
}

/* ==================== FILTER BAR ==================== */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.filter-btn {
    padding: 8px 16px;
    border: none;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 20px;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* ==================== FORMS ==================== */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
}

.input, .select, .textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    transition: border-color 0.2s;
}

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

.textarea {
    resize: vertical;
    min-height: 100px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.input-with-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-status .input {
    flex: 1;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tg-theme-hint-color);
}

.status-dot.active {
    background: var(--success);
}

/* ==================== BUTTONS ==================== */
.btn {
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-secondary {
    background: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
}

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

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.button-group .btn {
    flex: 1;
}

.full-width {
    width: 100%;
}

/* ==================== CHANNEL INFO ==================== */
.channel-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.channel {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: var(--radius-sm);
}

.channel-icon {
    font-size: 24px;
}

.channel-label {
    font-size: 12px;
    color: var(--tg-theme-hint-color);
}

.channel-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--primary);
}

/* ==================== TOAST ==================== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

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

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

/* ==================== LOADING ==================== */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--tg-theme-hint-color);
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--tg-theme-hint-color);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state-text {
    font-size: 14px;
}

/* ==================== SWITCH TOGGLE ==================== */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
}

input:checked + .slider {
    background: var(--gradient-purple);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.slider.round {
    border-radius: 28px;
}

.slider.round:before {
    border-radius: 50%;
}

/* ==================== AUTOPILOT ==================== */
.autopilot-status-card {
    background: var(--gradient-purple);
    color: white;
}

.autopilot-status-card .card-title {
    color: white;
}

.autopilot-status-card .card-description {
    color: rgba(255, 255, 255, 0.8);
}

.autopilot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.autopilot-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

#autopilot-status-text {
    font-size: 13px;
    font-weight: 500;
}

.schedule-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.schedule-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: var(--radius-sm);
}

.schedule-time {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary);
    min-width: 50px;
}

.schedule-type {
    font-size: 13px;
    color: var(--tg-theme-text-color);
}

/* ==================== ANALYTICS ==================== */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.analytics-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: var(--radius-sm);
}

.analytics-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.analytics-label {
    font-size: 12px;
    color: var(--tg-theme-hint-color);
    margin-top: 4px;
}

/* ==================== QUEUE LIST ==================== */
.queue-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    max-height: 250px;
    overflow-y: auto;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: var(--radius-sm);
}

.queue-time {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    min-width: 45px;
}

.queue-title {
    flex: 1;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==================== TOPICS ==================== */
.topics-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.topic-tag {
    padding: 8px 14px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.topic-tag.active {
    background: var(--primary);
    color: white;
}

/* ==================== SETTINGS ROW ==================== */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.setting-label {
    font-size: 14px;
    font-weight: 500;
}

.setting-desc {
    font-size: 12px;
    color: var(--tg-theme-hint-color);
}

.select-small {
    width: auto;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
}
