/* Professional UX-Focused Color Theme for Collabacker */

/* ============================================
   LIGHT THEME VARIABLES
   ============================================ */
:root {
    /* Background Colors */
    --bg-primary: #F9FAFB;
    --bg-surface: #FFFFFF;
    
    /* Primary Accent Colors */
    --color-primary: #4F46E5;
    --color-primary-hover: #4338CA;
    --color-secondary: #06B6D4;
    
    /* Text Colors */
    --text-primary: #111827;
    --text-secondary: #6B7280;
    
    /* Border Colors */
    --border-color: #E5E7EB;
    
    /* Status Colors */
    --color-success: #10B981;
    --color-warning: #F59E0B;
    --color-error: #EF4444;
    
    /* Shadow */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* ============================================
   DARK THEME VARIABLES
   ============================================ */
[data-bs-theme="dark"] {
    /* Background Colors */
    --bg-primary: #0F172A;
    --bg-surface: #1E293B;
    
    /* Primary Accent Colors */
    --color-primary: #6366F1;
    --color-primary-hover: #818CF8;
    --color-secondary: #06B6D4;
    
    /* Text Colors */
    --text-primary: #F9FAFB;
    --text-secondary: #94A3B8;
    
    /* Border Colors */
    --border-color: #334155;
    
    /* Status Colors */
    --color-success: #34D399;
    --color-warning: #FBBF24;
    --color-error: #F87171;
}

/* ============================================
   BASE STYLES
   ============================================ */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* ============================================
   NAVIGATION
   ============================================ */
.navbar {
    background-color: var(--bg-surface) !important;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text-primary) !important;
}

.navbar-nav .nav-link {
    font-weight: 500;
    color: var(--text-secondary) !important;
    transition: color 0.2s ease;
}

.navbar-nav .nav-link:hover {
    color: var(--color-primary) !important;
}

.navbar-toggler {
    border-color: var(--border-color);
}

.navbar-toggler-icon {
    filter: invert(0.5);
}

[data-bs-theme="dark"] .navbar-toggler-icon {
    filter: invert(1);
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease-in-out;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    color: var(--text-primary);
}

/* Remove border from colored dashboard stat cards */
div.card.bg-info,
div.card.bg-primary,
div.card.bg-success,
div.card.bg-warning,
div.card.bg-danger,
div.card.commission-highlight,
.card.commission-highlight {
    border: 0 !important;
    box-shadow: none !important;
}

.card.bg-info,
.card.bg-primary,
.card.bg-success,
.card.bg-warning,
.card.bg-danger,
.bg-info,
.bg-primary,
.bg-success,
.bg-warning,
.bg-danger,
.commission-highlight {
    border: 0 !important;
}

/* Dashboard Stats Cards - Compact Design */
.bg-primary {
    background-color: var(--color-primary) !important;
    color: white !important;
}

.bg-success {
    background-color: var(--color-success) !important;
    color: white !important;
}

.bg-info {
    background-color: var(--color-secondary) !important;
    color: white !important;
}

.bg-warning {
    background-color: var(--color-warning) !important;
    color: white !important;
}

/* Compact stat cards */
.stat-card-compact {
    border-radius: 1rem !important;
}

.stat-card-compact .card-body {
    padding: 0.5rem 0.75rem !important;
}

.stat-card-compact i {
    font-size: 2rem !important;
    margin-bottom: 0.25rem !important;
}

.stat-card-compact h3 {
    font-size: 2rem !important;
    margin-bottom: 0.15rem !important;
    font-weight: 600;
}

.stat-card-compact p {
    font-size: 0.875rem !important;
    margin-bottom: 0 !important;
}

/* Custom stat card colors */
.stat-in-contact {
    background-color: #3B82F6 !important;
    color: white !important;
}

.stat-outreach {
    background-color: #FBBF24 !important;
    color: #111827 !important;
}

.stat-current {
    background-color: #FEF3C7 !important;
    color: #111827 !important;
}

.stat-completed {
    background-color: #34D399 !important;
    color: white !important;
}

.stat-affiliate {
    background-color: #A78BFA !important;
    color: white !important;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
}

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

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

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

.btn-success:hover {
    background-color: #059669;
    border-color: #059669;
}

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

.btn-danger:hover {
    background-color: #DC2626;
    border-color: #DC2626;
}

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

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

/* ============================================
   FORMS
   ============================================ */
.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-control,
.form-select {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-surface);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* ============================================
   TABLES
   ============================================ */
.table {
    color: var(--text-primary);
    margin-bottom: 0;
}

.table th {
    border-top: none;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem 0.75rem;
    color: var(--text-secondary);
}

.table td {
    padding: 1rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

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

/* ============================================
   BADGES
   ============================================ */
.badge {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
}

.badge.bg-primary {
    background-color: var(--color-primary) !important;
}

.badge.bg-success {
    background-color: var(--color-success) !important;
}

.badge.bg-warning {
    background-color: var(--color-warning) !important;
    color: #111827 !important;
}

.badge.bg-danger {
    background-color: var(--color-error) !important;
}

.badge.bg-secondary {
    background-color: var(--text-secondary) !important;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    border-radius: 0.5rem;
    border: none;
    font-weight: 500;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
    border-left: 4px solid var(--color-success);
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--color-error);
    border-left: 4px solid var(--color-error);
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--color-warning);
    border-left: 4px solid var(--color-warning);
}

.alert-info {
    background-color: rgba(6, 182, 212, 0.1);
    color: var(--color-secondary);
    border-left: 4px solid var(--color-secondary);
}

/* ============================================
   MODALS
   ============================================ */
.modal-content {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-surface);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-surface);
}

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

.btn-close {
    filter: var(--bs-btn-close-white-filter);
}

[data-bs-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ============================================
   DROPDOWN
   ============================================ */
.dropdown-menu {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.dropdown-item {
    color: var(--text-primary);
}

.dropdown-item:hover {
    background-color: var(--bg-primary);
    color: var(--color-primary);
}

.dropdown-divider {
    border-top: 1px solid var(--border-color);
}

.dropdown-item-text {
    color: var(--text-primary);
}

/* ============================================
   SORTABLE TABLE
   ============================================ */
.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

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

.sortable:after {
    content: '\f0dc';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 0.75rem;
    opacity: 0.5;
    font-size: 0.75rem;
}

.sortable.sort-asc:after {
    content: '\f0de';
    opacity: 1;
}

.sortable.sort-desc:after {
    content: '\f0dd';
    opacity: 1;
}

/* ============================================
   STATUS INDICATORS
   ============================================ */
.status-indicator {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-contract_sent { background-color: var(--text-secondary); }
.status-active { background-color: var(--color-primary); }
.status-completed { background-color: var(--color-success); }
.status-cancelled { background-color: var(--color-error); }
.status-pending { background-color: var(--color-warning); }
.status-paid { background-color: var(--color-success); }
.status-overdue { background-color: var(--color-error); }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h5 {
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   TABS - Smaller and Lighter with Oval Shape
   ============================================ */
.nav-tabs .nav-link {
    padding: 0.4rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: 20px;
    color: var(--text-secondary);
    background-color: transparent;
    transition: all 0.2s ease;
    margin-right: 0.25rem;
}

.nav-tabs .nav-link:hover {
    color: var(--color-primary);
    background-color: rgba(79, 70, 229, 0.1);
}

.nav-tabs .nav-link.active {
    color: white;
    background-color: var(--color-primary);
    font-weight: 600;
}

[data-bs-theme="dark"] .nav-tabs .nav-link:hover {
    background-color: rgba(99, 102, 241, 0.15);
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active {
    background-color: var(--color-primary);
}

.nav-tabs {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* Lighter grey and charcoal colors */
.bg-secondary {
    background-color: #94A3B8 !important;
    color: white !important;
}

.bg-dark {
    background-color: #374151 !important;
    color: white !important;
}

[data-bs-theme="dark"] .bg-secondary {
    background-color: #64748B !important;
}

[data-bs-theme="dark"] .bg-dark {
    background-color: #1F2937 !important;
}

/* ============================================
   MISC TEXT COLORS
   ============================================ */
.text-muted {
    color: var(--text-secondary) !important;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */

/* Tablet (up to 992px) */
@media (max-width: 992px) {
    /* Reduce heading sizes for tablets */
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    /* Stack stat cards better */
    .col-md-3, .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Better button spacing */
    .d-flex.gap-2 {
        gap: 0.5rem !important;
        flex-wrap: wrap;
    }
}

/* Mobile Phones (up to 768px) */
@media (max-width: 768px) {
    /* Reduce container padding */
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    /* Tighter card padding */
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
    }
    
    /* Stack button groups vertically */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group > .btn {
        margin-bottom: 0.25rem;
        width: 100%;
    }
    
    /* Larger touch targets for buttons */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.95rem;
    }
    
    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Stack action buttons */
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 1rem;
    }
    
    .d-flex.justify-content-between > * {
        width: 100%;
    }
    
    /* Better table handling */
    .table-responsive {
        border-radius: 0.375rem;
        margin: 0 -0.75rem;
        width: calc(100% + 1.5rem);
    }
    
    .table {
        font-size: 0.85rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.5rem;
    }
    
    /* Hide less important table columns on mobile */
    .table .d-none.d-md-table-cell {
        display: none !important;
    }
    
    /* Navbar improvements */
    .navbar-nav {
        padding-top: 0.5rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    /* Modal improvements */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    /* Form improvements */
    .form-control,
    .form-select {
        font-size: 1rem;
        padding: 0.625rem 0.75rem;
    }
    
    .form-label {
        font-size: 0.95rem;
        margin-bottom: 0.375rem;
    }
    
    /* Stat cards - better mobile layout */
    .stat-card-compact h3 {
        font-size: 1.5rem !important;
    }
    
    .stat-card-compact p {
        font-size: 0.75rem !important;
    }
    
    /* Better spacing for mobile */
    .mb-4 {
        margin-bottom: 1.5rem !important;
    }
    
    .mt-4 {
        margin-top: 1.5rem !important;
    }
    
    /* Dropdown improvements */
    .dropdown-menu {
        width: 100%;
        max-width: 400px;
    }
    
    /* Badge sizing */
    .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
    
    /* Tabs - stack on mobile */
    .nav-tabs {
        flex-wrap: wrap;
    }
    
    .nav-tabs .nav-link {
        font-size: 0.8rem;
        padding: 0.35rem 1rem;
        margin-bottom: 0.25rem;
    }
}

/* Extra Small Phones (up to 576px) */
@media (max-width: 576px) {
    /* Even smaller headings */
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    /* Full width cards */
    .card {
        margin-bottom: 1rem;
    }
    
    /* Reduce font sizes further */
    body {
        font-size: 0.9rem;
    }
    
    .btn {
        font-size: 0.875rem;
    }
    
    /* Stack all columns */
    .row > [class*='col-'] {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 0.75rem;
    }
    
    /* Notification dropdown - full width */
    #notificationsList {
        max-height: 300px !important;
    }
    
    .dropdown-menu {
        min-width: 100vw !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        border-radius: 0;
    }
    
    /* Form row stacking */
    .row.g-3 > * {
        padding: 0.5rem;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   BUTTON ICONS - Remove any dots or underlines
   ============================================ */
.btn i {
    text-decoration: none !important;
}

a.btn {
    text-decoration: none !important;
}

a.btn:hover {
    text-decoration: none !important;
}

/* ============================================
   OUTREACH ACTION GRID - 2x2 Layout
   ============================================ */
.outreach-action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    width: fit-content;
}

.outreach-action-grid > .btn,
.outreach-action-grid > a.btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

.outreach-action-grid > .btn::after,
.outreach-action-grid > a.btn::after,
.outreach-action-grid .btn::after,
.outreach-action-grid a.btn::after {
    content: none !important;
    display: none !important;
}

/* ============================================
   TABLE ACTION BUTTONS - Centered Icons
   ============================================ */
table .btn,
table a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

table .btn::after,
table a.btn::after {
    content: none !important;
    display: none !important;
}

/* Remove underline from + buttons in platform and email columns */
.btn-link {
    text-decoration: none !important;
}

.btn-link:hover {
    text-decoration: none !important;
}

/* ============================================
   ANIMATIONS
   ============================================ */
.page-enter {
    opacity: 0;
    transform: translateY(1rem);
    animation: pageEnter 0.3s ease-out forwards;
}

@keyframes pageEnter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   THEME TOGGLE BUTTON (Optional)
   ============================================ */
.theme-toggle {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background-color: var(--bg-primary);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Force scrollbars to always show for all scroll-sync tables */
.scroll-sync-bottom.table-responsive {
    overflow-x: scroll !important;
}

.scroll-sync-top {
    overflow-x: scroll !important;
}

/* Tier-2: mobile-friendly long tables.
   Wrap horizontal scroll on small screens for influencer/brand/invoice lists. */
@media (max-width: 991.98px) {
    .table-compact,
    .table-hover,
    .table-sm {
        font-size: 0.85rem;
    }
    /* Allow tables that aren't already wrapped to scroll horizontally inside cards */
    .card-body > .table:not(.table-borderless) {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

/* Make first column sticky on small screens for very wide tables */
@media (max-width: 767.98px) {
    .table-sticky-first th:first-child,
    .table-sticky-first td:first-child {
        position: sticky;
        left: 0;
        background: var(--bs-body-bg, #fff);
        z-index: 2;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
    }
}
