:root {
    
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3d3d3d;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-tertiary: #888888;
    --accent-primary: #00c853;
    --accent-secondary: #ff3d00;
    --accent-warning: #ff9100;
    --accent-info: #2979ff;
    --border-color: #404040;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --hover-bg: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #eeeeee;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #888888;
    --accent-primary: #00c853;
    --accent-secondary: #ff3d00;
    --accent-warning: #ff6d00;
    --accent-info: #2962ff;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --hover-bg: rgba(0, 0, 0, 0.04);
}


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

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


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

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-width: 538px;
}


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

.header h1 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    font-size: 1.2rem;
    transition: background-color 0.2s ease;
}

.theme-toggle:hover {
    background-color: var(--hover-bg);
}

.status {
    width: 8px;
    height: 8px;
    border: 0;
    border-radius: 50%;
    position: absolute;
    right: 16px;
    top: 16px;
    background-color: var(--accent-warning);
}

.status.connected {
    background-color: var(--accent-primary);
}

.status.disconnected {
    background-color: var(--accent-secondary);
}


.controls {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    width: 100%;
}

.btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    height: auto;
    flex: 1 1 auto;
    min-width: 150px;
    justify-content: center;
    text-align: center;
}

.btn:hover {
    background-color: var(--hover-bg);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

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

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

.btn-warning {
    background-color: var(--accent-warning);
    color: white;
    border-color: var(--accent-warning);
}

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


.stats-bar {
    display: flex;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
    width: 100%;
}

.stat-item {
    background-color: var(--bg-secondary);
    padding: 16px;
    border-radius: 4px;
    text-align: center;
    border: 1px solid var(--border-color);
    flex: 1 1 auto;
    min-width: 150px;
    justify-content: center;
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-primary);
}


.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 250px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
}

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

.filter-select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 140px;
}

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


.media-list {
    display: grid;
    gap: 12px;
}

.media-item {
    background-color: var(--bg-secondary);
    border-radius: 4px;
    padding: 16px;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.media-item:hover {
    background-color: var(--hover-bg);
    box-shadow: var(--shadow);
}

.media-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}

.media-name {
    flex: 1;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-word;
}

.media-date {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    white-space: nowrap;
}

.media-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 1.1rem;
}

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

.control-btn.active {
    color: var(--accent-primary);
}

.control-btn.warning {
    color: var(--accent-warning);
}

.control-btn.danger {
    color: var(--accent-secondary);
}

.media-status {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.convert {
    background-color: rgba(0, 200, 83, 0.1);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
}

.status-badge.pause {
    background-color: rgba(255, 145, 0, 0.1);
    color: var(--accent-warning);
    border: 1px solid var(--accent-warning);
}

.status-badge.remove {
    background-color: rgba(255, 61, 0, 0.1);
    color: var(--accent-secondary);
    border: 1px solid var(--accent-secondary);
}

.status-badge.restart {
    background-color: rgba(41, 121, 255, 0.1);
    color: var(--accent-info);
    border: 1px solid var(--accent-info);
}

.status-badge.without-convert {
    background-color: rgba(156, 39, 176, 0.1);
    color: #9c27b0;
    border: 1px solid #9c27b0;
}


.loading {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px;
    text-align: center;
}

.loading.active {
    display: flex;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-left: 2px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}


.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 4px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}


.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background-color: var(--bg-secondary);
    padding: 16px;
    border-radius: 4px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.stat-card .label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}


::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

.status-connected {
    color: var(--accent-primary) !important;
}

.status-error {
    color: var(--accent-secondary) !important;
}

.status-unknown {
    color: var(--accent-warning) !important;
}


.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 4px;
    z-index: 10000;
    box-shadow: var(--shadow);
    border: 1px solid;
    animation: slideIn 0.3s ease;
}

.notification.success {
    background-color: rgba(0, 200, 83, 0.1);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.notification.error {
    background-color: rgba(255, 61, 0, 0.1);
    color: var(--accent-secondary);
    border-color: var(--accent-secondary);
}


.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-content h2, .tab-content h3, .tab-content h4 {
    margin: 0 0 16px
}


.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-primary);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    min-width: 35px;
}


.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

.form-input, .form-select {
    width: 100%;
    padding: 8px 10px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.875rem;
}

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


.no-data, .no-tasks, .no-torrents, .no-history {
    text-align: center;
    padding: 20px;
    color: var(--text-tertiary);
    font-style: italic;
}


.health-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.health-status.healthy {
    background: var(--accent-primary);
}

.health-status.unhealthy {
    background: var(--accent-secondary);
}

.health-status.unknown {
    background: var(--accent-warning);
}


@media (max-width: 768px) {
    .controls .btn {
        min-width: 0
    }

    .controls .btn .text {
        display: none
    }

    .container {
        padding: 16px 16px 0;
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    .header h1 {
        font-size: 16px;
    }

    .media-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .media-date {
        align-self: flex-end;
    }

    .stats-bar, .notifications-grid {
        display: flex;
        flex-direction: column;
        margin-top: 12px;
        margin-bottom: 20px;
        order: 9999;
    }

    .header {
        order: 1;
    }

    .controls {
        order: 2;
    }

    .filters, .tabs {
        order: 3;
    }

    .media-list, .tab-content {
        order: 4;
        flex: 1;
    }

    .loading {
        order: 5;
    }
}

@media (max-width: 480px) {
    .stats-bar {
        grid-template-columns: 1fr;
    }

    .filters {
        flex-direction: column;
    }

    .search-input {
        min-width: auto;
    }
}