/* CSS Variables for theming - ContactScout Brand Colors */
:root {
    /* Brand Navy palette */
    --bg-primary: #0a1628;
    --bg-secondary: #142238;
    --bg-tertiary: #1c2d42;
    --bg-input: #0d1a2d;
    /* Text colors */
    --text-primary: #f5f5f7;
    --text-secondary: #a1a6b4;
    --text-tertiary: #6b7280;
    /* Brand Cyan accent */
    --accent-color: #00b4d8;
    --accent-hover: #0096b4;
    --accent-glow: rgba(0, 180, 216, 0.3);
    /* Status colors */
    --success-color: #34c759;
    --warning-color: #ff9500;
    --error-color: #ff453a;
    /* Border and shadows */
    --border-color: #253548;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    /* Font */
    --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* App Container */
.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 40px 20px 30px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo-icon {
    font-size: 2.5rem;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-color), #0077b5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Main Content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Search Section */
.search-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.input-group .optional {
    font-weight: 400;
    color: var(--text-tertiary);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    font-size: 1.1rem;
    pointer-events: none;
}

.input-group input[type="url"],
.input-group input[type="text"] {
    width: 100%;
    padding: 14px 14px 14px 44px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-group input::placeholder {
    color: var(--text-tertiary);
}

.hint {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

/* Options Group */
.options-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.checkbox-label input:checked + .checkmark {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.checkbox-label input:checked + .checkmark::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.label-text {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
}

.label-icon {
    font-size: 1rem;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-icon {
    font-size: 1.1em;
}

/* Progress Section */
.progress-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow-md);
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #0077b5);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Results Section */
.results-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    flex: 1;
}

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

.results-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.export-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Results Table */
.results-table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.results-table th,
.results-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.results-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}

.results-table tbody tr {
    transition: background 0.15s;
}

.results-table tbody tr:hover {
    background: var(--bg-primary);
}

.results-table tbody tr:last-child td {
    border-bottom: none;
}

.col-select {
    width: 40px;
    text-align: center;
}

.col-name {
    min-width: 150px;
}

.col-role {
    min-width: 200px;
}

.col-source {
    width: 120px;
}

.col-linkedin,
.col-email {
    width: 100px;
    text-align: center;
}

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

.contact-name {
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
}

.contact-name:hover {
    color: var(--accent-color);
}

.contact-role {
    color: var(--text-secondary);
}

.source-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

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

.source-linkedin {
    background: rgba(0, 122, 255, 0.15);
    color: var(--accent-color);
}

.source-both {
    background: rgba(88, 86, 214, 0.15);
    color: #5856d6;
}

.link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--accent-color);
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.2s;
}

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

.link-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
    font-size: 1.1rem;
}

/* Modal */
.modal {
    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;
    padding: 20px;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--error-color);
    color: white;
}

.modal-body {
    padding: 24px;
}

.modal-field {
    margin-bottom: 16px;
}

.modal-field:last-child {
    margin-bottom: 0;
}

.modal-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

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

.modal-value a {
    color: var(--accent-color);
    text-decoration: none;
}

.modal-value a:hover {
    text-decoration: underline;
}

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

/* Footer */
.footer {
    text-align: center;
    padding: 24px 20px;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.results-table tbody tr {
    animation: fadeIn 0.3s ease;
}

/* Responsive - Tablet */
@media (max-width: 900px) {
    .settings-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .results-header {
        flex-wrap: wrap;
    }

    .results-filter {
        order: 3;
        flex: 100%;
        max-width: 100%;
        margin: 0;
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .app {
        padding: 10px;
    }

    .header {
        padding: 20px 10px 16px;
    }

    .logo-icon {
        font-size: 2rem;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .search-section,
    .results-section,
    .progress-section {
        padding: 14px;
        border-radius: var(--radius-md);
    }

    .input-group input[type="url"],
    .input-group input[type="text"] {
        padding: 12px 12px 12px 40px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    .options-group {
        padding: 12px;
        gap: 14px;
    }

    .option-row {
        flex-direction: column;
        gap: 14px;
    }

    .checkbox-label {
        padding: 8px 0;
    }

    .settings-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 12px;
    }

    .setting-item select {
        padding: 10px;
        font-size: 16px; /* Prevents iOS zoom */
    }

    .button-group {
        flex-direction: column;
        gap: 10px;
    }

    .btn {
        width: 100%;
        padding: 14px 20px;
    }

    /* Progress section mobile */
    .progress-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .progress-stats {
        flex-wrap: wrap;
        gap: 6px;
    }

    #progress-time {
        position: absolute;
        right: 14px;
        top: 14px;
    }

    .progress-section {
        position: relative;
    }

    .progress-text {
        font-size: 0.9rem;
    }

    .progress-subtext {
        font-size: 0.8rem;
        word-break: break-word;
    }

    /* Results section mobile */
    .results-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .results-header h2 {
        font-size: 1.1rem;
    }

    .results-filter {
        max-width: 100%;
        margin: 0;
    }

    .export-buttons {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
    }

    .export-buttons .btn {
        padding: 10px 8px;
        font-size: 0.8rem;
    }

    .export-buttons .btn-icon {
        display: none;
    }

    /* Table mobile optimizations */
    .results-table-container {
        margin: 0 -14px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .results-table {
        font-size: 0.85rem;
    }

    .results-table th,
    .results-table td {
        padding: 10px 8px;
    }

    /* Hide role column on very small screens */
    .col-role {
        display: none;
    }

    .col-name {
        min-width: 100px;
    }

    .col-source {
        width: 70px;
    }

    .source-badge {
        padding: 3px 6px;
        font-size: 0.7rem;
    }

    .col-linkedin,
    .col-email {
        width: 44px;
    }

    .link-btn {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }

    /* Modal mobile */
    .modal {
        padding: 10px;
        align-items: flex-end;
    }

    .modal-content {
        max-height: 85vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }

    .modal-value {
        word-break: break-all;
    }

    .footer {
        padding: 16px 10px;
        font-size: 0.8rem;
    }
}

/* Very small screens */
@media (max-width: 400px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .export-buttons {
        grid-template-columns: 1fr 1fr;
    }

    .export-buttons .btn:last-child {
        grid-column: span 2;
    }

    .logo h1 {
        font-size: 1.3rem;
    }

    .col-source {
        display: none;
    }
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Advanced Settings */
.advanced-settings {
    margin-bottom: 20px;
}

.advanced-settings summary {
    cursor: pointer;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
    transition: all 0.2s;
}

.advanced-settings summary:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.advanced-settings[open] summary {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    margin-bottom: 0;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    border-top: 1px solid var(--border-color);
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setting-item label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.setting-item select {
    padding: 8px 12px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
}

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

.setting-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Option Row */
.option-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

/* Progress Section Enhanced */
.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.progress-stats .separator {
    color: var(--border-color);
}

#progress-time {
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

/* Dual Progress Bars */
.dual-progress {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 16px;
}

.progress-track {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 12px 16px;
}

.progress-track-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.track-icon {
    font-size: 1.1rem;
}

.track-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.track-status {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.track-status.active {
    color: var(--accent-color);
}

.track-status.complete {
    color: var(--success-color);
}

.track-status.error {
    color: var(--error-color);
}

.progress-bar-linkedin .progress-fill {
    background: linear-gradient(90deg, #0077b5, #00a0dc);
}

.progress-bar-website .progress-fill {
    background: linear-gradient(90deg, var(--success-color), #5bd679);
}

.track-detail {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-top: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-overall {
    text-align: center;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.progress-overall .progress-text {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Button variants */
.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #e68600;
}

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

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

/* Results Filter */
.results-filter {
    flex: 1;
    max-width: 300px;
    margin: 0 16px;
}

.results-filter input {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

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

.results-filter input::placeholder {
    color: var(--text-tertiary);
}

/* Sortable columns */
.sortable {
    cursor: pointer;
    user-select: none;
}

.sortable:hover {
    background: var(--bg-primary);
}
