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

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6b7280;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background-color: #f9fafb;
    --card-background: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease-in-out;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
header {
    text-align: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    color: white;
    border-radius: var(--radius-lg);
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

header .subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

.hubspot-status {
    margin-top: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.28);
    font-size: 0.95rem;
    font-weight: 600;
}

.hubspot-status-icon {
    font-size: 1rem;
    line-height: 1;
}

.hubspot-status.connected {
    background: rgba(16, 185, 129, 0.22);
    border-color: rgba(16, 185, 129, 0.55);
}

/* Search Section */
.search-section {
    background: var(--card-background);
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-weight: 600;
    color: var(--text-primary);
}

.input-group textarea {
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
}

.input-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

.button-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

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

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

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

.btn-secondary:hover {
    background-color: #4b5563;
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background-color: var(--background-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-text {
    display: inline;
}

.btn-loader {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-loader.hidden,
.btn-text.hidden {
    display: none;
}

/* Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Error Container */
.error-container {
    margin-bottom: 20px;
}

.error-container.hidden {
    display: none;
}

.error-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    color: var(--error-color);
}

.error-icon {
    font-size: 1.2rem;
}

.dismiss-btn {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--error-color);
    opacity: 0.7;
    transition: var(--transition);
}

.dismiss-btn:hover {
    opacity: 1;
}

/* Loading Container */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.loading-container.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* Results Section */
.results-section {
    background: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.results-section.hidden {
    display: none;
}

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

.results-header h2 {
    font-size: 1.3rem;
    color: var(--text-primary);
}

.result-count {
    background-color: var(--primary-color);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
}

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

.results-table thead {
    background-color: var(--background-color);
}

.results-table th {
    padding: 15px 20px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: var(--transition);
}

.results-table th:hover {
    background-color: #e5e7eb;
}

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

.results-table th.sort-asc .sort-icon::after {
    content: '↑';
}

.results-table th.sort-desc .sort-icon::after {
    content: '↓';
}

.results-table td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.results-table tbody tr {
    transition: var(--transition);
}

.results-table tbody tr:hover {
    background-color: #f3f4f6;
}

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

/* Table Cell Specific Styles */
.agency-name {
    font-weight: 600;
    color: var(--primary-color);
}

.phone-number {
    font-family: 'Courier New', monospace;
    white-space: nowrap;
}

.email-address {
    color: var(--primary-color);
}

.email-address a {
    color: inherit;
    text-decoration: none;
}

.email-address a:hover {
    text-decoration: underline;
}

.website a {
    color: var(--primary-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.website a:hover {
    text-decoration: underline;
}

.website a::after {
    content: '↗';
    font-size: 0.8rem;
}

.not-found {
    color: var(--text-secondary);
    font-style: italic;
}

.address {
    max-width: 300px;
    line-height: 1.4;
}

/* Employee Badge */
.employee-badge {
    display: inline-block;
    padding: 4px 10px;
    background-color: #e0e7ff;
    color: #3730a3;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Export Options */
.export-options {
    display: flex;
    gap: 15px;
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
    background-color: var(--background-color);
}

/* No Results */
.no-results {
    text-align: center;
    padding: 60px 20px;
    background: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.no-results.hidden {
    display: none;
}

.no-results-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 20px;
}

.no-results h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.no-results p {
    color: var(--text-secondary);
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
    margin-top: 40px;
}

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

    header {
        padding: 12px 15px;
    }

    header h1 {
        font-size: 1.3rem;
    }

    .hubspot-status {
        margin-top: 12px;
        width: 100%;
        justify-content: center;
    }

    .search-section {
        padding: 20px;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .results-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .results-table th,
    .results-table td {
        padding: 12px 15px;
    }

    .export-options {
        flex-direction: column;
    }

    .export-options .btn {
        width: 100%;
    }
}

/* Animation for new rows */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.results-table tbody tr:nth-child(1) { animation-delay: 0.05s; }
.results-table tbody tr:nth-child(2) { animation-delay: 0.1s; }
.results-table tbody tr:nth-child(3) { animation-delay: 0.15s; }
.results-table tbody tr:nth-child(4) { animation-delay: 0.2s; }
.results-table tbody tr:nth-child(5) { animation-delay: 0.25s; }
/* HubSpot Status Cell */
.hs-status-cell {
    white-space: nowrap;
}

.hs-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.hs-status--checking {
    color: #6b7280;
    background: #f3f4f6;
}

.hs-status--found {
    color: #065f46;
    background: #d1fae5;
}

.hs-status--created {
    color: #1e40af;
    background: #dbeafe;
}

.hs-status--error {
    color: #991b1b;
    background: #fee2e2;
}

.hs-status--skipped {
    color: #6b7280;
    font-style: italic;
}
