/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 40px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

/* Auth forms */
.auth-form {
    max-width: 400px;
    margin: 0 auto;
    padding: 30px;
    background: #f9f9f9;
    border-radius: 8px;
}

.auth-form h2 {
    margin-bottom: 20px;
    color: #333;
}

.auth-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
}

.auth-form button {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background 0.3s;
}

.auth-form button:hover {
    background: #5568d3;
}

.auth-form p {
    text-align: center;
    margin-top: 15px;
    color: #666;
}

.auth-form a {
    color: #667eea;
    text-decoration: none;
}

.auth-form a:hover {
    text-decoration: underline;
}

/* User info */
.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f0f0f0;
    border-radius: 5px;
    margin-bottom: 30px;
}

#logout-btn {
    padding: 8px 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#logout-btn:hover {
    background: #c82333;
}

/* Search section */
.search-section {
    background: #f9f9f9;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.search-section h2 {
    margin-bottom: 20px;
    color: #333;
}

.form-row {
    margin-bottom: 20px;
}

.form-row input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
}

.form-row label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #555;
}

.form-row input[type="checkbox"] {
    width: auto;
}

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

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.form-group input,
.form-group select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
}

.primary-btn {
    width: 100%;
    padding: 15px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background 0.3s;
}

.primary-btn:hover {
    background: #218838;
}

/* Saved searches */
.saved-searches {
    margin-top: 40px;
}

.saved-searches h2 {
    margin-bottom: 20px;
    color: #333;
}

.search-item {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #667eea;
}

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

.search-header h3 {
    color: #333;
    font-size: 1.3em;
}

.interval-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.82em;
    font-weight: 600;
    background: #f0f0f0;
    color: #555;
}

.status-badge {
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
}

.status-badge.active {
    background: #d4edda;
    color: #155724;
}

.status-badge.inactive {
    background: #f8d7da;
    color: #721c24;
}

.search-criteria {
    color: #666;
    margin-bottom: 15px;
    font-size: 0.95em;
}

.search-actions {
    display: flex;
    gap: 10px;
}

.search-actions button {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: opacity 0.3s;
}

.search-actions button:hover {
    opacity: 0.8;
}

.btn-run {
    background: #007bff;
    color: white;
}

.btn-view {
    background: #17a2b8;
    color: white;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

/* Interval row (email + interval selector side by side) */
.interval-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.interval-select {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #555;
    font-size: 0.95em;
}

.interval-select select {
    padding: 7px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.95em;
    background: white;
}

/* Criteria group labels */
.criteria-group-label {
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #888;
    margin: 18px 0 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e0e0e0;
}

/* Condition checkboxes */
.form-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin-bottom: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #555;
    font-size: 0.95em;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #e65000;
}

/* Source toggle */
.source-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.source-btn {
    flex: 1;
    padding: 11px 20px;
    background: #e9ecef;
    color: #555;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
}

.source-btn:hover {
    background: #d0d4d8;
}

#source-btn-avtonet.active {
    background: #667eea;
    color: white;
}

#source-btn-as24.active {
    background: #e65000;
    color: white;
}

#source-btn-automobile.active {
    background: #009640;
    color: white;
}

/* Source badges in search list */
.source-badge {
    display: inline-block;
    font-size: 0.75em;
    padding: 2px 8px;
    border-radius: 10px;
    margin-right: 6px;
    vertical-align: middle;
    font-weight: bold;
}

.source-badge.avtonet {
    background: #667eea;
    color: white;
}

.source-badge.as24 {
    background: #e65000;
    color: white;
}

.source-badge.automobile {
    background: #009640;
    color: white;
}

/* Mode toggle */
.mode-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.mode-btn {
    flex: 1;
    padding: 12px 20px;
    background: #e9ecef;
    color: #555;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: background 0.2s, color 0.2s, transform 0.1s;
}

.mode-btn:hover {
    background: #d0d4d8;
}

.mode-btn.active {
    background: #667eea;
    color: white;
}

.mode-btn.active:hover {
    background: #5568d3;
}

#direct-url {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.95em;
    font-family: monospace;
}

#url-section small {
    display: block;
    margin-top: 6px;
    color: #888;
    font-size: 0.85em;
}

.url-badge {
    display: inline-block;
    background: #667eea;
    color: white;
    font-size: 0.75em;
    padding: 2px 8px;
    border-radius: 10px;
    margin-right: 6px;
    vertical-align: middle;
}

/* Inline results panel */
.results-panel {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

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

.results-count {
    font-weight: 600;
    color: #444;
    font-size: 0.95em;
}

.btn-delete-all {
    padding: 5px 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82em;
    font-weight: 600;
}

.btn-delete-all:hover {
    background: #c82333;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    gap: 10px;
}

.result-thumb {
    width: 110px;
    height: 75px;
    object-fit: cover;
    border-radius: 5px;
    flex-shrink: 0;
    background: #f0f0f0;
}

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

.result-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.9em;
    min-width: 0;
}

.result-info strong {
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-info span {
    color: #666;
    font-size: 0.85em;
}

.result-price {
    font-size: 1em;
    font-weight: 700;
    color: #1a7a3c;
}

.result-price-call {
    color: #e65000;
    font-style: italic;
}

.result-meta {
    color: #888;
    font-size: 0.82em;
}

.result-info a {
    color: #667eea;
    font-size: 0.85em;
    text-decoration: none;
}

.result-info a:hover {
    text-decoration: underline;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
}

.btn-delete-result {
    padding: 4px 10px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
}

.btn-delete-result:hover {
    background: #c82333;
}

.btn-mark-sold {
    padding: 4px 10px;
    background: #fd7e14;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
}

.btn-mark-sold:hover {
    background: #e8690a;
}

.btn-check-sold {
    padding: 5px 12px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82em;
    font-weight: 600;
}

.btn-check-sold:hover {
    background: #545b62;
}

.btn-check-sold:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Sold listing */
.result-sold {
    opacity: 0.65;
    background: #fff5f5;
    border-radius: 4px;
    padding-left: 6px;
}

.result-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sold-badge {
    display: inline-block;
    background: #dc3545;
    color: white;
    font-size: 0.72em;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    letter-spacing: 0.04em;
}

/* Inline note input */
.result-note {
    margin-top: 4px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.82em;
    color: #555;
    width: 100%;
    max-width: 380px;
    background: #fafafa;
}

.result-note:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.no-results {
    color: #888;
    font-size: 0.9em;
    font-style: italic;
}

.searching-status {
    color: #667eea;
    font-style: normal;
    font-weight: 500;
}

/* Avto.net URL preview box */
.url-preview-box {
    margin-top: 16px;
    padding: 12px 14px;
    background: #f4f6ff;
    border: 1px solid #d0d8f0;
    border-radius: 6px;
}

.url-preview-box label {
    display: block;
    font-size: 0.8em;
    color: #666;
    margin-bottom: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.url-preview-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.url-preview-row input[type="text"] {
    flex: 1;
    font-size: 0.78em;
    font-family: monospace;
    color: #444;
    background: #fff;
    border: 1px solid #c8d0e8;
    border-radius: 4px;
    padding: 6px 8px;
    cursor: text;
}

.url-preview-row button {
    white-space: nowrap;
    padding: 6px 14px;
    font-size: 0.82em;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.url-preview-row button:hover {
    background: #5568d4;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .search-actions {
        flex-direction: column;
    }

    .search-actions button {
        width: 100%;
    }
}
