/* Base Styles */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Views */
.view {
    display: none;
    min-height: 100vh;
}

.view.active {
    display: block;
}

/* Login Page */
.login-container {
    max-width: 420px;
    margin: 0 auto;
    padding: 60px 20px;
}

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

.login-header .logo {
    width: 60px;
    height: 60px;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header .subtitle {
    color: var(--text-secondary);
}

.login-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--border-color);
    padding: 4px;
    border-radius: var(--radius);
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-form {
    display: none;
    background: var(--surface);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.login-form.active {
    display: block;
}

/* Login Footer */
.login-footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 13px;
}

.login-footer .powered-by {
    margin-bottom: 4px;
}

.login-footer .powered-by a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.login-footer .powered-by a:hover {
    text-decoration: underline;
}

.login-footer .copyright {
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* Dashboard Footer */
.dashboard-footer {
    text-align: center;
    padding: 32px 20px;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
}

.dashboard-footer .terms-text {
    margin-bottom: 8px;
    font-size: 12px;
}

.dashboard-footer .terms-text a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.dashboard-footer .terms-text a:hover {
    text-decoration: underline;
}

.dashboard-footer .powered-by {
    font-size: 12px;
}

.dashboard-footer .powered-by a {
    color: var(--primary-color);
    text-decoration: none;
}

.dashboard-footer .powered-by a:hover {
    text-decoration: underline;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-section-header {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    margin: 20px 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

/* Match Preferences Grid */
.match-preferences-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    background: var(--background);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.match-preferences-grid .form-group-inline {
    margin-bottom: 0;
}

.match-preferences-grid .form-group-inline.full-width {
    grid-column: 1 / -1;
}

.form-group-inline label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group-inline input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
}

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

@media (max-width: 600px) {
    .match-preferences-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* API Docs Try It Section Labels */
.try-it-section-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 12px 0 8px 0;
}

.try-it-prefs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.try-input-small {
    flex: 0 0 80px;
    max-width: 100px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

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

.btn-secondary:hover {
    background: #d1d5db;
}

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

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

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

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

/* Navbar logout button - dark text for light partner navbar */
.navbar .btn-outline {
    border-color: var(--border-color);
    color: var(--text-primary);
}

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

/* Admin navbar logout button - light colors on dark background */
.navbar-admin .btn-outline {
    border-color: rgba(255, 255, 255, 0.5);
    color: #ffffff;
}

.navbar-admin .btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.8);
}

.btn-block {
    width: 100%;
}

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

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-text {
    font-size: 18px;
    font-weight: 600;
}

.partner-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.tenant-logo {
    height: 36px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    border-radius: 4px;
}

/* Contact Info Bar */
.contact-info-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 8px 24px;
    background: var(--background);
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.contact-info-bar .contact-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.contact-info-bar .contact-item {
    color: var(--text-primary);
}

.contact-info-bar a.contact-item {
    color: var(--primary-color);
    text-decoration: none;
}

.contact-info-bar a.contact-item:hover {
    text-decoration: underline;
}

.navbar-menu {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: var(--radius);
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.nav-link.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.navbar-admin {
    background: #1e293b;
    border-bottom-color: #334155;
}

.navbar-admin .brand-text,
.navbar-admin .nav-link {
    color: #e2e8f0;
}

.navbar-admin .nav-link:hover {
    background: #334155;
    color: white;
}

.navbar-admin .nav-link.active {
    background: var(--primary-color);
    color: white;
}

/* Main Content */
.main-content {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Sections */
.section {
    display: none;
}

.section.active {
    display: block;
}

.section h2 {
    font-size: 24px;
    margin-bottom: 24px;
}

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

.section-header h2 {
    margin-bottom: 0;
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.section-desc-inline {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.filters {
    display: flex;
    gap: 12px;
}

.filters select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.stat-pending .stat-value { color: var(--warning-color); }
.stat-accepted .stat-value { color: var(--primary-color); }
.stat-imported .stat-value { color: var(--success-color); }
.stat-rejected .stat-value { color: var(--danger-color); }

/* Cards */
.card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.card h3 {
    font-size: 18px;
    margin-bottom: 16px;
}

.dashboard-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .dashboard-row {
        grid-template-columns: 1fr;
    }
}

/* Commission Info */
.commission-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.commission-rate,
.commission-earned {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: var(--background);
    border-radius: var(--radius);
}

.commission-earned span:last-child {
    font-weight: 600;
    color: var(--success-color);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 12px;
}

/* Tables */
.table-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

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

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

.data-table th {
    background: var(--background);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.data-table tbody tr:hover {
    background: var(--background);
}

.data-table .loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px;
    background: var(--surface);
    border-top: 1px solid var(--border-color);
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 14px;
}

.pagination-info span {
    font-weight: 500;
    color: var(--text-primary);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending { background: #fef3c7; color: #92400e; }
.status-accepted { background: #dbeafe; color: #1e40af; }
.status-imported { background: #d1fae5; color: #065f46; }
.status-rejected { background: #fee2e2; color: #991b1b; }

/* Lookup Section */
.lookup-container {
    max-width: 600px;
}

.lookup-form {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.lookup-result {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.recommendation {
    padding: 16px;
    border-radius: var(--radius);
    font-weight: 600;
    text-align: center;
    margin-bottom: 16px;
}

.recommendation.accept {
    background: #d1fae5;
    color: #065f46;
}

.recommendation.reject {
    background: #fee2e2;
    color: #991b1b;
}

.result-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

/* Push Form */
.push-form {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    max-width: 700px;
}

.form-actions {
    margin-top: 24px;
}

.push-result {
    margin-top: 16px;
    padding: 16px;
    border-radius: var(--radius);
}

.push-result.success {
    background: #d1fae5;
    color: #065f46;
}

.push-result.error {
    background: #fee2e2;
    color: #991b1b;
}

/* API Docs */
.docs-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.doc-card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.doc-card h3 {
    margin-bottom: 12px;
}

.doc-card p {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
}

code {
    background: var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* Docs Token Display */
.auth-token-display {
    background: var(--background);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.auth-token-display label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

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

.token-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    background: var(--surface);
}

/* Try It Section */
.try-it-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.try-it-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.try-input {
    flex: 1;
    min-width: 150px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
}

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

.btn-try {
    min-width: 80px;
}

.try-result {
    margin-top: 12px;
    background: #1e293b;
    border-radius: var(--radius);
    overflow: hidden;
}

.try-result pre {
    padding: 16px;
    margin: 0;
    color: #10b981;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    line-height: 1.5;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

.try-result.error pre {
    color: #ef4444;
}

/* Settings */
.settings-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 700px;
}

.settings-card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.settings-card h3 {
    margin-bottom: 16px;
}

.credential-row {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.credential-row:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.credential-row label {
    width: 120px;
    font-weight: 500;
}

.credential-value {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.credential-value input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: monospace;
}

.source-list,
.permission-list {
    list-style: none;
}

.source-list li,
.permission-list li {
    padding: 8px 12px;
    background: var(--background);
    margin-bottom: 8px;
    border-radius: var(--radius);
}

.permission-list li.enabled {
    background: #d1fae5;
}

.permission-list li.disabled {
    background: #fee2e2;
}

/* Bulk Actions */
.bulk-actions {
    background: var(--surface);
    padding: 16px 24px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

#selected-count {
    font-weight: 500;
}

/* Error Message */
.error-message {
    color: var(--danger-color);
    font-size: 14px;
    margin-top: 12px;
}

.help-text {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
}

.help-text a {
    color: var(--primary-color);
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    background: #1e293b;
    color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

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

.toast.error {
    background: var(--danger-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 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;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    margin: 20px;
    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: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 24px;
}

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

/* Form Overlay (for Add Partner) */
.form-overlay {
    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;
}

.form-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.form-modal-header h3 {
    font-size: 18px;
    margin: 0;
}

.form-modal form {
    padding: 24px;
}

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

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px;
    background: var(--background);
    border-radius: var(--radius);
}

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

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Credentials Modal */
.credentials-modal {
    max-width: 500px;
}

.credentials-content {
    padding: 24px;
}

.credentials-warning {
    background: #fef3c7;
    color: #92400e;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-weight: 500;
    text-align: center;
}

.credential-display {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.credential-display:last-of-type {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.credential-display label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

.credential-value-copy {
    display: flex;
    align-items: center;
    gap: 8px;
}

.credential-value-copy code {
    flex: 1;
    background: #1e293b;
    color: #e2e8f0;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    word-break: break-all;
}

.credential-value-copy .token-display {
    font-size: 12px;
    max-height: 80px;
    overflow-y: auto;
}

.credentials-modal .form-actions {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
}

/* Help text for forms */
.form-group .help-text {
    display: block;
    margin-top: 4px;
    text-align: left;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        height: auto;
        padding: 12px;
    }

    .navbar-menu {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 12px;
        flex-wrap: wrap;
    }

    .nav-link {
        padding: 6px 12px;
        font-size: 13px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .main-content {
        padding: 16px;
    }

    .form-modal {
        max-height: 100vh;
        border-radius: 0;
    }

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