/*
 * TacticalHQ Dashboard - Modern SaaS Design
 * Inspired by Semrush
 */

/* ========== RESET & BASE ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: #1f2937;
    background: #f7fafc;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ========== LAYOUT STRUCTURE ========== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 260px;
    background: #1a202c;
    color: #e5e7eb;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo img {
    height: 32px;
    width: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    padding: 0 20px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease, border-left 0.2s ease;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: #ffffff;
    border-left-color: #818cf8;
}

.nav-item-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    opacity: 0.8;
}

.nav-item.active .nav-item-icon {
    opacity: 1;
}

.nav-item-sub {
    padding-left: 60px;
    font-size: 13px;
}

.nav-item-sub .nav-item-icon {
    font-size: 16px;
}

.nav-item-label {
    font-size: 14px;
    font-weight: 500;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.user-menu:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 13px;
    overflow: hidden;
    position: relative;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-avatar-default-icon {
    font-size: 16px;
}

.user-info {
    flex: 1;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #e5e7eb;
}

.user-role {
    font-size: 11px;
    color: #6b7280;
}

.dropdown-arrow {
    font-size: 10px;
    color: #6b7280;
    transition: transform 0.2s ease;
}

.user-menu.active .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-top: 8px;
}

.user-dropdown.show {
    max-height: 200px;
    overflow-y: auto;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    color: #e5e7eb;
    text-decoration: none;
    transition: background 0.2s ease;
    border-radius: 6px;
    margin: 4px;
}

.user-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-dropdown-item .nav-item-icon {
    font-size: 16px;
}

.user-dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 4px;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ========== TOPBAR ========== */
.topbar {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.breadcrumb-item {
    color: #6b7280;
    text-decoration: none;
    transition: color 0.2s ease;
}

.breadcrumb-item:hover {
    color: #3b82f6;
}

.breadcrumb-item.active {
    color: #1f2937;
    font-weight: 600;
}

.breadcrumb-separator {
    color: #d1d5db;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-btn {
    padding: 8px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #4b5563;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

/* ========== CONTENT AREA ========== */
.content-area {
    flex: 1;
    padding: 32px;
}

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 8px;
}

.page-subtitle {
    font-size: 14px;
    color: #6b7280;
}

/* ========== STATS BAR ========== */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #111827;
    line-height: 1;
}

.stat-change {
    font-size: 12px;
    margin-top: 8px;
    font-weight: 500;
}

.stat-change.positive {
    color: #10b981;
}

.stat-change.negative {
    color: #ef4444;
}

/* ========== CLIENTS GRID ========== */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 24px;
}

.client-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    padding: 25px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.client-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border-color: #667eea;
}

.client-card.active {
    border-color: #28a745;
    background: linear-gradient(135deg, #ffffff 0%, #f0fff4 100%);
}

.client-card.pending {
    border-color: #ffc107;
    background: linear-gradient(135deg, #ffffff 0%, #fffbf0 100%);
}

.client-platform-badges {
    position: absolute;
    top: 15px;
    left: 15px;
    display: flex;
    gap: 6px;
    z-index: 5;
}

.platform-badge {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    cursor: help;
    padding: 6px;
}

.platform-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.platform-badge img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.client-settings-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    color: #5f6368;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
    z-index: 10;
}

.client-settings-btn:hover {
    background: rgba(95, 99, 104, 0.1);
    color: #202124;
    transform: rotate(90deg);
}

.client-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    margin-top: 55px;
}

.client-logo {
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    padding: 8px;
}

.client-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.client-info {
    flex: 1;
    padding-right: 50px;
}

.client-name {
    font-size: 1.4em;
    font-weight: bold;
    color: #1e3c72;
    margin-bottom: 2px;
    display: flex;
    align-items: flex-start;
    gap: 4px;
    line-height: 1.2;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.7em;
    flex-shrink: 0;
}

.status-badge.active {
    background: #28a745;
    color: white;
}

.status-badge.pending {
    background: #ffc107;
    font-size: 0.65em;
}

.new-report-badge {
    display: inline-block;
    margin-left: 10px;
    padding: 4px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.client-website {
    font-size: 0.9em;
    color: #6c757d;
}

.client-description {
    color: #6c757d;
    font-size: 0.95em;
    line-height: 1.5;
    margin: 15px 0;
}

.client-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 15px 0;
}

.meta-badge {
    padding: 5px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-industry {
    background: #e3f2fd;
    color: #1976d2;
}

.badge-season {
    background: #fff3e0;
    color: #f57c00;
}

.badge-status-active {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-status-pending {
    background: #fff8e1;
    color: #f57f17;
}

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

.btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    text-align: center;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

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

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

.btn-secondary {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #dee2e6;
}

.btn-secondary:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #667eea;
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.last-update {
    font-size: 0.85em;
    color: #6c757d;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

/* Report History Styles */
.report-history {
    margin-top: 15px;
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
}

.history-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #667eea;
    font-weight: 500;
    font-size: 0.9em;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: #f8f9fa;
}

.history-toggle:hover {
    background: #e9ecef;
    color: #5568d3;
}

.history-toggle .arrow {
    transition: transform 0.3s ease;
    font-size: 0.8em;
}

.history-toggle.active .arrow {
    transform: rotate(90deg);
}

.history-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    margin-top: 10px;
}

.history-dropdown.show {
    max-height: 400px;
    overflow-y: auto;
}

.history-loading,
.history-empty {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    font-size: 0.9em;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateX(4px);
}

.history-item-date {
    font-size: 0.85em;
    color: #6c757d;
}

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

.history-item-agents {
    font-size: 0.75em;
    color: #667eea;
    font-weight: 500;
}

.history-item-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.history-item-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85em;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.history-item-link:hover {
    background: #667eea;
    color: white;
}

.history-item-delete {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 14px;
}

.history-item-delete:hover {
    background: #fee2e2;
    color: #dc2626;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
}

/* ========== LOADING ========== */
.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== MODALS ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.show,
.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.modal-body {
    color: #4b5563;
    line-height: 1.6;
    margin-bottom: 24px;
}

.modal-actions,
.prompt-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-cancel {
    padding: 10px 24px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.btn-save {
    padding: 10px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

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

/* Block body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

/* ========== QUEUE STATUS MODAL ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.queue-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.7em;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

.queue-stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    color: white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.queue-stat-value {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 5px;
}

.queue-stat-label {
    font-size: 0.85em;
    opacity: 0.95;
}

.queue-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 10px;
}

.queue-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.95em;
    color: #6b7280;
    border-radius: 6px 6px 0 0;
    transition: all 0.3s;
}

.queue-tab:hover {
    background: #f3f4f6;
    color: #374151;
}

.queue-tab.active {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.queue-jobs-list {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.queue-job-item {
    padding: 15px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.3s;
}

.queue-job-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.queue-job-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.queue-job-client {
    font-weight: 600;
    color: #1f2937;
    font-size: 1.05em;
}

.queue-job-id {
    color: #6b7280;
    font-size: 0.85em;
    font-family: monospace;
}

.queue-job-meta {
    display: flex;
    gap: 15px;
    font-size: 0.9em;
    color: #6b7280;
}

.queue-job-error {
    margin-top: 10px;
    padding: 10px;
    background: #fee2e2;
    border-left: 3px solid #ef4444;
    border-radius: 4px;
    color: #991b1b;
    font-size: 0.9em;
}

.queue-empty {
    text-align: center;
    padding: 40px;
    color: #9ca3af;
}

.queue-empty-icon {
    font-size: 3em;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* ========== FORM STYLES ========== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: #111827;
    background: white;
    transition: all 0.2s;
}

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

.form-group textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

.form-group small {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
}

.form-group small code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
}

@media (max-width: 768px) {
    .content-area {
        padding: 20px;
    }

    .topbar {
        padding: 12px 20px;
    }

    .stats-bar {
        grid-template-columns: 1fr;
    }
}
