/* Main styles */
:root {
    /* Light mode variables */
    --bg-color: #f5f5f5;
    --text-color: #333;
    --card-bg: #fff;
    --border-color: #ddd;
    --primary-color: #007aff;
    --success-color: #34c759;
    --warning-color: #ff9500;
    --danger-color: #ff3b30;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --input-bg: #fff;
    --sort-select-bg: #f5f5f5;
    --header-bg: #fff;
    --hover-bg: #f8f8f8;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.main-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    background-color: var(--bg-color);
    transition: background-color 0.3s ease;
}

/* Furo-style theme toggle */
.theme-toggle-container {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1000;
    padding: 6px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background-color: var(--bg-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

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

.theme-toggle-icon {
    font-size: 18px;
    color: var(--text-color);
    transition: transform 0.5s ease, color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Apply slight rotation animation on hover */
.theme-toggle-container:hover .theme-toggle-icon {
    transform: rotate(30deg);
}

h1 {
    text-align: center;
    padding: 15px 0;
    margin: 0;
    font-size: 32px;
    font-weight: 600;
    color: var(--text-color);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: color 0.3s ease;
}

/* Tab container with proper width constraints */
.tab-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    width: 100%;
    background-color: var(--bg-color);
    margin: 0 auto; /* Center on desktop */
    transition: background-color 0.3s ease;
}

/* Tab buttons container styles */
.tab-buttons {
    display: flex;
    width: 100%;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    margin: 0 auto; /* Center the tabs */
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Fixed width container for just the tab buttons */
.tab-buttons-wrapper {
    width: 100%;
    max-width: 800px;
    display: flex;
}

/* Individual tab styling */
.tab-button {
    flex: 1;
    padding: 12px 0;
    border: none;
    background-color: transparent;
    cursor: pointer;
    font-weight: 500;
    font-size: 16px;
    color: var(--primary-color);
    transition: all 0.2s;
    position: relative;
    text-align: center;
}

/* Active tab style */
.tab-button.active {
    color: var(--primary-color);
}

/* Active indicator line */
.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--primary-color);
    transition: background-color 0.3s ease;
}

.tab-content {
    display: none;
    padding: 15px;
    width: 100%;
    box-sizing: border-box;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Search section */
.search-container {
    display: flex;
    margin-bottom: 15px;
    position: relative;
    width: 100%;
}

#search-input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    box-shadow: var(--shadow);
    width: 100%;
    box-sizing: border-box;
    padding-right: 50px; /* Make room for the button */
    background-color: var(--input-bg);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

#search-button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.loading, .error {
    text-align: center;
    padding: 15px;
    display: none;
}

.loading {
    color: var(--primary-color);
    transition: color 0.3s ease;
}

.error {
    color: var(--danger-color);
    margin-bottom: 15px;
    transition: color 0.3s ease;
}

/* Results styles */
.result-row {
    margin-bottom: 15px;
    padding: 15px;
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 1.3;
    /* Word breaking and wrapping rules */
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    color: var(--text-color);
    transition: color 0.3s ease;
}

.title-icon {
    height: 1em;  /* Size relative to the text */
    width: auto;  /* Maintain aspect ratio */
    vertical-align: middle;
    margin-right: 0.3em;  /* Space between icon and text */
}

.metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.7;
    transition: color 0.3s ease;
}

.buttons {
    display: flex;
    gap: 10px;
}

.download-button, .transmission-button {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.download-button {
    background-color: var(--success-color);
    color: white;
    transition: background-color 0.3s ease;
}

.transmission-button {
    background-color: var(--primary-color);
    color: white;
    flex: 1;
    transition: background-color 0.3s ease;
}

.download-button:hover {
    background-color: #2fb350;
}

.transmission-button:hover {
    background-color: #0069d9;
}

.download-button i, .transmission-button i {
    margin-right: 6px;
}

.mr-2 {
    margin-right: 6px;
}

/* Notification styling */
.notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
    max-width: 90%;
    text-align: center;
}

.notification.error {
    background-color: rgba(255, 59, 48, 0.9);
}

.notification.success {
    background-color: rgba(52, 199, 89, 0.9);
}

.notification.show {
    opacity: 1;
}

/* Sort controls styling */
.sort-controls {
    margin: 0 0 15px 0;
    padding: 15px;
    border-radius: 10px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.sort-buttons-container {
    display: flex;
    align-items: center;
}

.sort-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    margin-right: 10px;
    transition: color 0.3s ease;
}

.sort-select-container {
    display: flex;
    align-items: center;
    flex: 1;
}

.sort-select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background-color: var(--sort-select-bg);
    color: var(--text-color);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 32px;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.sort-direction {
    margin-left: 10px;
    padding: 8px;
    border-radius: 8px;
    background-color: var(--sort-select-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.sort-direction:hover {
    background-color: var(--hover-bg);
}

/* Download directory menu styles */
.download-dir-menu {
    position: absolute;
    z-index: 1000;
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    overflow: hidden;
    animation: fadeIn 0.2s;
    margin-top: 5px;
    width: auto;
    min-width: 180px;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.download-dir-option {
    padding: 12px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.download-dir-option:last-child {
    border-bottom: none;
}

.download-dir-option:hover {
    background-color: var(--hover-bg);
}

.download-dir-option i {
    margin-right: 8px;
    color: var(--text-color);
    opacity: 0.7;
    transition: color 0.3s ease;
}

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

/* Ensure the transmission button shows a dropdown indicator */
.transmission-button {
    position: relative;
    padding-right: 28px;
}

.transmission-button::after {
    content: '\f0d7';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    right: 10px;
    font-size: 12px;
}

/* Status-specific styling */
.stopped .progress-fill {
    background-color: #8e8e93;
}

.downloading .progress-fill {
    background-color: var(--primary-color);
}

.seeding .progress-fill {
    background-color: var(--success-color);
}

/* Transmission button states */
.transmission-button-success {
    background-color: var(--success-color) !important;
}

.transmission-button-error {
    background-color: var(--danger-color) !important;
}

.transmission-button-disabled {
    background-color: var(--border-color) !important;
    cursor: not-allowed;
}

/* Existence badge for already downloaded torrents */
.existence-badge {
    display: none;
}

.existence-badge-visible {
    display: inline-block;
    background-color: var(--success-color);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 10px;
}

/* Result row for already downloaded torrents */
.result-row-exists {
    background-color: rgba(52, 199, 89, 0.1);
    border-left: 4px solid var(--success-color);
}

.dark-mode .result-row-exists {
    background-color: rgba(48, 209, 88, 0.1);
}

/* Download directory menu close button (mobile) */
.download-dir-close {
    padding: 15px;
    text-align: center;
    color: var(--danger-color);
    font-weight: bold;
    border-top: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.download-dir-close:hover {
    background-color: var(--hover-bg);
}

/* Dark mode variables */
.dark-mode,
.dark-mode html,
.dark-mode body {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --card-bg: #222;
    --border-color: #444;
    --primary-color: #0a84ff;
    --success-color: #30d158;
    --warning-color: #ff9f0a;
    --danger-color: #ff453a;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --input-bg: #333;
    --sort-select-bg: #333;
    --header-bg: #222;
    --hover-bg: #2a2a2a;
}

/* Large screens - ensure tabs have proper width */
@media (min-width: 1024px) {
    .tab-buttons {
        background-color: var(--header-bg);
        width: 100%;
        display: flex;
        justify-content: center;
    }
}

/* === UPDATED TORRENT ROW STYLES FOR MOBILE === */

/* Updated torrent row styling for mobile-friendly design */
.torrent-row {
    margin-bottom: 12px;
    padding: 12px;
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Torrent header with title and status */
.torrent-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.torrent-title {
    font-weight: 600;
    font-size: 15px;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    display: -webkit-box;
    display: box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    color: var(--text-color);
    transition: color 0.3s ease;
    flex: 1;
    padding-right: 8px;
}

.torrent-status-tag {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 12px;
    background-color: var(--border-color);
    color: var(--text-color);
    white-space: nowrap;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Status-specific tag colors */
.stopped .torrent-status-tag {
    background-color: #8e8e93;
    color: white;
}

.downloading .torrent-status-tag {
    background-color: var(--primary-color);
    color: white;
}

.seeding .torrent-status-tag {
    background-color: var(--success-color);
    color: white;
}

/* Progress container with bar and text */
.progress-container {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

.progress-bar {
    flex-grow: 1;
    height: 6px;
    background-color: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

.progress-fill {
    height: 100%;
    background-color: var(--success-color);
    transition: background-color 0.3s ease;
}

.progress-text {
    font-size: 12px;
    min-width: 48px;
    text-align: right;
    color: var(--text-color);
    opacity: 0.8;
    transition: color 0.3s ease;
}

/* Stats container for size, speeds, and date */
.torrent-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-color);
    opacity: 0.7;
    transition: color 0.3s ease;
}

.torrent-size {
    font-weight: 500;
}

.torrent-speeds {
    display: flex;
    gap: 8px;
}

.download-speed, .upload-speed {
    white-space: nowrap;
}

.torrent-added {
    font-size: 12px;
    opacity: 0.6;
    cursor: help;
}

/* Torrent action buttons */
.torrent-actions {
    display: flex;
    gap: 8px;
}

.torrent-action {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.torrent-action i {
    margin-right: 4px;
}

.torrent-start {
    background-color: var(--success-color);
    color: white;
    transition: background-color 0.3s ease;
}

.torrent-stop {
    background-color: var(--warning-color);
    color: white;
    transition: background-color 0.3s ease;
}

.torrent-remove {
    background-color: var(--danger-color);
    color: white;
    transition: background-color 0.3s ease;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    h1 {
        font-size: 24px;
        padding-right: 50px; /* Make room for theme toggle */
    }

    .theme-toggle-container {
        position: fixed;
        top: 12px;
        right: 12px;
        z-index: 1000;
        padding: 6px;
        border-radius: 50%;
        width: 18px;
        height: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        background-color: var(--bg-color);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        border: 1px solid var(--border-color);
        transition: background-color 0.3s ease, border-color 0.3s ease;
    }
    
    .theme-toggle-container:hover {
        background-color: var(--hover-bg);
    }
    
    .theme-toggle-icon {
        font-size: 14px;
        color: var(--text-color);
        transition: transform 0.5s ease, color 0.3s ease;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .tab-container {
        max-width: 100%;
        border-radius: 0;
        padding: 0 15px;
        box-sizing: border-box;
    }
    
    .tab-content {
        padding: 15px 0;
    }
    
    .search-container {
        flex-direction: row;
        position: relative;
        width: 100%;
    }
    
    #search-input {
        width: 100%;
        border-radius: 10px;
        padding-right: 50px; /* Make room for the button */
    }
    
    #search-button {
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .buttons {
        flex-wrap: wrap;
    }
    
    .download-button {
        padding: 8px;
        width: 40px;
        justify-content: center;
    }
    
    .download-button i {
        margin-right: 0;
    }
    
    .transmission-button {
        flex: 1;
    }
    
    /* Mobile sort controls */
    .sort-buttons-container {
        flex-direction: row;
    }
    
    .sort-select {
        width: 100%;
    }
    
    /* Fix tab-buttons wrapping */
    .tab-buttons {
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    .tab-button {
        padding: 10px 0;
    }
    
    .tab-button.active::after {
        height: 3px;
    }
    
    /* Adjust menu positioning for mobile */
    .download-dir-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 12px 12px 0 0;
        max-height: 50vh;
        overflow-y: auto;
        animation: slideUp 0.3s;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        width: 100%;
    }
    
    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    
    .download-dir-option {
        padding: 15px;
        border-bottom: 1px solid var(--border-color);
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    h1 {
        font-size: 22px;
        padding-right: 42px; /* Adjust for smaller toggle on small screens */
    }
    
    .theme-toggle-container {
        top: 8px;
        right: 8px;
    }
    
    .tab-button {
        font-size: 15px;
    }
    
    /* Fix tab-content padding */
    .tab-content {
        padding: 10px 0;
    }
}

/* Very small mobile devices */
@media (max-width: 380px) {
    .torrent-stats {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .torrent-size {
        width: 100%;
    }
    
    .torrent-speeds {
        flex: 1;
    }
    
    .torrent-action {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .torrent-action i {
        margin-right: 3px;
    }
}

@supports (-webkit-touch-callout: none) {
    /* iOS specific styles */
    body {
        /* Ensure background extends behind status bar */
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        min-height: 100vh;
        box-sizing: border-box;
    }
    
    /* Fix for iOS Safari status bar */
    html {
        background-color: var(--bg-color);
        transition: background-color 0.3s ease;
    }
    
    /* Ensure the theme toggle is visible and not under notch */
    .theme-toggle-container {
        top: calc(12px + env(safe-area-inset-top));
        right: calc(12px + env(safe-area-inset-right));
    }
    
    /* Adjust page padding for safe area */
    .tab-container {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Apply dark mode to html element as well */
html.dark-mode {
    background-color: var(--bg-color);
}

/* Ensure HTML background matches body for a seamless look */
html {
    background-color: var(--bg-color);
    transition: background-color 0.3s ease;
}

html, body {
    min-height: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    transition: background-color 0.3s ease;
}

/* ========== SCHEDULER STYLES ========== */

/* Notification badge on tab button */
.notification-badge {
    display: none;
    background-color: var(--danger-color);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
    min-width: 18px;
    text-align: center;
    align-items: center;
    justify-content: center;
}

/* Scheduler sub-navigation */
.scheduler-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    background-color: var(--card-bg);
    padding: 8px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.scheduler-nav-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background-color: transparent;
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.scheduler-nav-btn:hover {
    background-color: var(--hover-bg);
}

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

/* Scheduler actions bar */
.scheduler-actions {
    margin-bottom: 15px;
}

.create-task-button {
    width: 100%;
    padding: 12px 20px;
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    background-color: transparent;
    color: var(--primary-color);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s, border-color 0.2s;
}

.create-task-button:hover {
    background-color: var(--hover-bg);
    border-color: var(--primary-color);
}

/* Scheduler sections */
.scheduler-section {
    display: none;
}

.scheduler-section.active {
    display: block;
}

/* Task row styling */
.task-row {
    margin-bottom: 12px;
    padding: 15px;
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.task-row.paused {
    opacity: 0.7;
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.task-keyword {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-color);
    flex: 1;
    padding-right: 10px;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.3;
}

.task-status {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
    font-weight: 500;
}

.task-status.active {
    background-color: var(--success-color);
    color: white;
}

.task-status.paused {
    background-color: #8e8e93;
    color: white;
}

/* Task info row */
.task-info {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-color);
    opacity: 0.8;
}

.task-info span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.task-info i {
    opacity: 0.7;
}

/* Task times row */
.task-times {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.6;
}

.task-times span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Task action buttons */
.task-actions {
    display: flex;
    gap: 8px;
}

.task-action {
    padding: 8px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    transition: background-color 0.2s, transform 0.1s;
}

.task-action:hover {
    transform: scale(1.05);
}

.task-action:active {
    transform: scale(0.95);
}

.task-pause, .task-resume {
    background-color: var(--warning-color);
    color: white;
}

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

.task-edit {
    background-color: var(--border-color);
    color: var(--text-color);
}

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

/* History row styling */
.history-row {
    display: flex;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background-color: var(--card-bg);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.history-row.unread {
    border-left: 3px solid var(--primary-color);
}

.history-status {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.history-status.success {
    background-color: rgba(52, 199, 89, 0.15);
    color: var(--success-color);
}

.history-status.info {
    background-color: rgba(0, 122, 255, 0.15);
    color: var(--primary-color);
}

.history-status.warning {
    background-color: rgba(255, 149, 0, 0.15);
    color: var(--warning-color);
}

.history-status.error {
    background-color: rgba(255, 59, 48, 0.15);
    color: var(--danger-color);
}

.history-content {
    flex: 1;
    min-width: 0;
}

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

.history-keyword {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
}

.history-time {
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.6;
}

.history-details {
    font-size: 13px;
    color: var(--text-color);
    opacity: 0.8;
}

.history-title {
    font-weight: 500;
}

.history-message {
    font-style: italic;
}

/* Empty state styling */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-color);
    opacity: 0.6;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.4;
}

.empty-state p {
    margin: 5px 0;
}

.empty-hint {
    font-size: 13px;
    opacity: 0.7;
}

/* Modal styles */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: 12px;
    max-width: 450px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

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

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-color);
    cursor: pointer;
    padding: 5px;
    opacity: 0.6;
}

.modal-close:hover {
    opacity: 1;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
}

/* Form styles for task modal */
.task-form-modal form {
    padding: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    background-color: var(--input-bg);
    color: var(--text-color);
    box-sizing: border-box;
    transition: border-color 0.2s;
}

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

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.btn-cancel,
.btn-submit,
.btn-confirm {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-cancel {
    background-color: var(--border-color);
    color: var(--text-color);
    border: none;
}

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

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

.btn-submit:hover {
    opacity: 0.9;
}

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

.btn-danger:hover {
    opacity: 0.9;
}

/* Confirm dialog styling */
.confirm-dialog {
    max-width: 350px;
}

.confirm-dialog .modal-body p {
    margin: 0;
    font-size: 15px;
    color: var(--text-color);
}

/* Checkbox label in modals */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Mobile optimizations for scheduler */
@media (max-width: 768px) {
    .task-info {
        gap: 8px;
    }

    .task-info span {
        font-size: 12px;
    }

    .task-actions {
        flex-wrap: wrap;
    }

    .task-action {
        flex: 1;
        min-width: calc(25% - 6px);
    }

    .history-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .modal-content {
        max-height: 85vh;
        margin: 0 10px;
    }
}

@media (max-width: 480px) {
    .scheduler-nav {
        padding: 6px;
    }

    .scheduler-nav-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .task-row {
        padding: 12px;
    }

    .task-keyword {
        font-size: 14px;
    }

    .task-action {
        width: 34px;
        height: 34px;
        font-size: 12px;
    }

    .history-row {
        padding: 10px;
    }

    .history-status {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}

/* ========== FILM/SERIES TASK STYLES ========== */

/* Task type badge */
.task-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 500;
    flex-shrink: 0;
}

.task-type-badge.movie {
    background-color: rgba(255, 149, 0, 0.15);
    color: var(--warning-color);
}

.task-type-badge.series {
    background-color: rgba(0, 122, 255, 0.15);
    color: var(--primary-color);
}

/* Task keyword wrapper for inline display */
.task-keyword-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.task-keyword-wrapper .task-keyword {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Episode progress styling */
.task-progress {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    color: var(--primary-color);
}

/* Completed task status */
.task-status.completed {
    background-color: var(--success-color);
    color: white;
}

/* Completed task row */
.task-row.completed {
    opacity: 0.7;
    border-left: 3px solid var(--success-color);
}

.task-row.completed:hover {
    opacity: 0.85;
}

/* Reactivate button */
.task-reactivate {
    background-color: var(--success-color);
    color: white;
}

/* Series fields in form */
.series-fields {
    background-color: var(--hover-bg);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 18px;
    border: 1px solid var(--border-color);
}

.series-fields .form-row {
    margin-bottom: 0;
}

.series-fields .form-group {
    margin-bottom: 0;
}

/* Form hint text */
.form-hint {
    display: none;
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.6;
    margin-top: 4px;
}

/* Mobile optimizations for Film/Series */
@media (max-width: 480px) {
    .task-keyword-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .task-type-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* ========== LOGIN PAGE STYLES ========== */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
}

.login-box {
    background-color: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 400px;
    padding: 40px 30px;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 15px;
}

.login-header h1 {
    font-size: 24px;
    margin: 0;
    padding: 0;
    color: var(--text-color);
}

.login-subtitle {
    margin: 10px 0 0 0;
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.7;
}

.login-error {
    background-color: rgba(255, 59, 48, 0.1);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-info {
    background-color: rgba(0, 122, 255, 0.1);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form .form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
}

.login-form .form-group label i {
    opacity: 0.6;
    width: 16px;
}

.login-form .form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    background-color: var(--input-bg);
    color: var(--text-color);
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form .form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.login-form .form-group input::placeholder {
    color: var(--text-color);
    opacity: 0.4;
}

.login-button {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    background-color: var(--primary-color);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background-color 0.2s, transform 0.1s;
}

.login-button:hover {
    background-color: #0069d9;
}

.login-button:active {
    transform: scale(0.98);
}

/* User info in header */
.user-info {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.user-badge i {
    opacity: 0.7;
}

.logout-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s, border-color 0.2s;
}

.logout-button:hover {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}

/* Mobile optimizations for login */
@media (max-width: 480px) {
    .login-box {
        padding: 30px 20px;
    }

    .login-icon {
        width: 48px;
        height: 48px;
    }

    .login-header h1 {
        font-size: 20px;
    }

    .user-info {
        top: 8px;
        left: 8px;
    }

    .user-badge {
        padding: 4px 10px;
        font-size: 12px;
    }

    .logout-button {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/* iOS safe area for user info */
@supports (-webkit-touch-callout: none) {
    .user-info {
        top: calc(12px + env(safe-area-inset-top));
        left: calc(12px + env(safe-area-inset-left));
    }
}

/* ========== FILE BROWSER STYLES ========== */

/* File browser modal */
.file-browser-modal {
    max-width: 500px;
    width: 100%;
}

.file-browser-modal .modal-header {
    background-color: var(--hover-bg);
}

.file-browser-modal .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-browser-modal .modal-header h3 i {
    color: #f5c542;
}

/* Path input area */
.file-browser-path {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background-color: var(--hover-bg);
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}

.file-browser-path input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
    background-color: var(--input-bg);
    color: var(--text-color);
}

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

.file-browser-path button {
    padding: 8px 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.file-browser-path button:hover {
    background-color: #0069d9;
}

/* Directory list */
.file-browser-list {
    max-height: 350px;
    overflow-y: auto;
}

.file-browser-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    transition: background-color 0.2s;
}

.file-browser-item:hover {
    background-color: var(--hover-bg);
}

.file-browser-item:last-child {
    border-bottom: none;
}

.file-browser-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.file-browser-item i.fa-folder {
    color: #f5c542;
}

.file-browser-item i.fa-level-up-alt {
    color: var(--text-color);
    opacity: 0.6;
}

.file-browser-item span {
    flex: 1;
    font-size: 14px;
    color: var(--text-color);
}

.file-browser-item.parent {
    background-color: var(--hover-bg);
    font-style: italic;
}

.file-browser-item.parent span {
    opacity: 0.8;
}

/* Loading state */
.file-browser-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-color);
    opacity: 0.7;
    gap: 10px;
}

/* Error state */
.file-browser-error {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--danger-color);
    gap: 10px;
}

/* Empty state */
.file-browser-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-color);
    opacity: 0.5;
    gap: 10px;
}

.file-browser-empty i {
    font-size: 32px;
    color: #f5c542;
}

/* Browse option in download menu */
.download-dir-option.browse-option {
    border-top: 1px solid var(--border-color);
    color: var(--primary-color);
    font-weight: 500;
}

.download-dir-option.browse-option i {
    color: var(--primary-color);
    opacity: 1;
}

/* Recent paths in download menu */
.download-dir-option.recent-path {
    font-size: 13px;
}

.download-dir-option.recent-path i {
    color: var(--text-color);
    opacity: 0.5;
}

/* Separator in download menu */
.download-dir-separator {
    border-top: 1px solid var(--border-color);
    margin: 0;
    padding: 0;
    height: 0;
}

/* Folder select group (select + browse button) */
.folder-select-group {
    display: flex;
    gap: 8px;
}

.folder-select-group select {
    flex: 1;
}

.folder-select-group button {
    padding: 10px 14px;
    background-color: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-color);
    transition: background-color 0.2s, border-color 0.2s;
}

.folder-select-group button:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.folder-select-group button i {
    font-size: 14px;
}

/* Custom path display */
.custom-path-display {
    margin-top: 8px;
    padding: 8px 12px;
    background-color: var(--hover-bg);
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-path-display i {
    color: #f5c542;
}

/* Mobile optimizations for file browser */
@media (max-width: 768px) {
    .file-browser-modal {
        max-width: 100%;
        margin: 10px;
        max-height: 80vh;
    }

    .file-browser-list {
        max-height: 300px;
    }

    .file-browser-item {
        padding: 14px 15px;
    }

    .file-browser-path input {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .file-browser-path {
        flex-direction: column;
        gap: 10px;
    }

    .file-browser-path input {
        width: 100%;
    }

    .file-browser-path button {
        width: 100%;
    }

    .folder-select-group {
        flex-direction: column;
    }

    .folder-select-group button {
        width: 100%;
    }
}

/* Bouton nouveau dossier */
.btn-new-folder {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s, color 0.2s;
}

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

.btn-new-folder i {
    font-size: 14px;
}

/* Footer avec bouton nouveau dossier */
.file-browser-modal .modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-footer-right {
    display: flex;
    gap: 10px;
    margin-left: auto;
}