/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* Sections */
section {
    padding: 30px;
    border-bottom: 1px solid #e5e7eb;
}

section:last-child {
    border-bottom: none;
}

h2 {
    color: #1f2937;
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: 600;
}

/* API Credentials Section */
.credentials-container {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: wrap;
    background: #f9fafb;
    padding: 20px;
    border-radius: 8px;
}

.credentials-container .input-group {
    flex: 1;
    min-width: 200px;
}

/* Input Groups */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-weight: 500;
    color: #4b5563;
    font-size: 0.9rem;
}

.input-group input[type="text"],
.input-group input[type="password"],
.input-group select,
.input-group textarea {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
}

/* Settings Row */
.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 25px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.info-tooltip {
    display: inline-block;
    width: 20px;
    height: 20px;
    background: #6b7280;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 20px;
    font-size: 12px;
    cursor: help;
    transition: background 0.3s;
}

.info-tooltip:hover {
    background: #4b5563;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-top: 10px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.keywords-import-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-fallback {
    background: #9ca3af;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 14px;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.2s ease;
}

.btn-fallback:hover:not(:disabled) {
    background: #6b7280;
    transform: scale(1.05);
}

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

.btn-check-standard {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.2s ease;
}

.btn-check-standard:hover:not(:disabled) {
    background: #2563eb;
    transform: scale(1.05);
}

.btn-check-ads {
    background: #8b5cf6;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 4px;
    transition: all 0.2s ease;
}

.btn-check-ads:hover:not(:disabled) {
    background: #7c3aed;
    transform: scale(1.05);
}

.btn-check-standard:disabled,
.btn-check-ads:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Row color coding */
.row-has-local-pack {
    background-color: #ecfdf5 !important;
}

.row-has-local-pack:hover {
    background-color: #d1fae5 !important;
}

.row-no-local-pack {
    background-color: #ffffff;
}

.row-no-local-pack:hover {
    background-color: #f9fafb;
}

/* Status Messages */
.status-message {
    margin-left: 10px;
    font-size: 0.9rem;
    font-weight: 500;
}

.status-message.success {
    color: #10b981;
}

.status-message.error {
    color: #ef4444;
}

/* Loading Indicator */
.loading-container {
    text-align: center;
    padding: 40px;
    background: #f9fafb;
    border-radius: 8px;
    margin: 20px 30px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#progress-info {
    margin-top: 15px;
    font-size: 0.9rem;
    color: #6b7280;
}

/* Results Section */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.batch-actions {
    display: flex;
    gap: 8px;
}

.results-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    width: 200px;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-left: 10px;
    background: white;
    cursor: pointer;
}

/* Table */
.table-container {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #f9fafb;
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #4b5563;
    border-bottom: 2px solid #e5e7eb;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th:hover {
    background: #f3f4f6;
}

.sort-indicator {
    margin-left: 5px;
    opacity: 0.4;
    font-size: 0.8rem;
}

th.sorted-asc .sort-indicator,
th.sorted-desc .sort-indicator {
    opacity: 1;
}

tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.2s;
}

tbody tr:hover {
    background: #f9fafb;
}

td {
    padding: 12px;
}

/* Difficulty Colors */
.difficulty-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.9rem;
}

.difficulty-easy {
    background: #d4f4dd;
    color: #14532d;
}

.difficulty-medium {
    background: #fef3c7;
    color: #78350f;
}

.difficulty-hard {
    background: #fee2e2;
    color: #7f1d1d;
}

/* Search Intent Badges */
.intent-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.intent-informational {
    background: #dbeafe;
    color: #1e3a8a;
}

.intent-navigational {
    background: #e0e7ff;
    color: #312e81;
}

.intent-commercial {
    background: #fce7f3;
    color: #831843;
}

.intent-transactional {
    background: #dcfce7;
    color: #14532d;
}

/* Local Pack Indicator */
.local-pack-yes {
    color: #10b981;
    font-weight: 600;
}

.local-pack-no {
    color: #6b7280;
}

/* Results Summary */
.results-summary {
    margin-top: 20px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 6px;
    text-align: center;
    color: #6b7280;
}

/* Error Container */
.error-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.error-message {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.error-message h3 {
    color: #ef4444;
    margin-bottom: 15px;
}

.error-message p {
    margin-bottom: 20px;
    color: #4b5563;
}

/* Cost Estimator */
.cost-estimator {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.cost-header h3 {
    margin: 0 0 15px 0;
    color: #78350f;
    font-size: 1.2rem;
}

.cost-breakdown {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 4px;
}

.cost-item.cost-total {
    background: #f59e0b;
    color: white;
    font-size: 1.1rem;
    margin-top: 5px;
}

.cost-label {
    color: #78350f;
}

.cost-item.cost-total .cost-label {
    color: white;
}

.cost-value {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #92400e;
}

.cost-item.cost-total .cost-value {
    color: white;
}

.cost-note {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f59e0b;
    color: #92400e;
    text-align: center;
}

/* Cost Tracker Section */
.cost-tracker-section {
    background: #f9fafb;
}

.cost-tracker-container {
    background: white;
    border: 2px solid #10b981;
    border-radius: 8px;
    padding: 20px;
}

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

.tracker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    background: #f0fdf4;
    border-radius: 6px;
    border: 1px solid #86efac;
}

.tracker-label {
    font-size: 0.9rem;
    color: #166534;
    margin-bottom: 8px;
}

.tracker-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #10b981;
    font-family: 'Courier New', monospace;
}

/* Footer */
footer {
    background: #1f2937;
    color: #9ca3af;
    padding: 20px;
    text-align: center;
}

footer a {
    color: #60a5fa;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .settings-row {
        grid-template-columns: 1fr;
    }

    .credentials-container {
        flex-direction: column;
    }

    .results-header {
        flex-direction: column;
        align-items: stretch;
    }

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

    .filter-input {
        width: 100%;
    }

    .table-container {
        overflow-x: scroll;
    }
}