/* Media Planner Custom Styles */

.channel-card.available {
    border-color: #28a745;
}

.channel-card.unavailable {
    border-color: #ffc107;
    opacity: 0.7;
}

.channel-card.unavailable .form-check-input {
    cursor: not-allowed;
}

/* Table Container Full Width */
.table-responsive {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Only remove padding for table containers - use specific class approach */
.table-card .card-body {
    padding: 0 !important;
}

/* Modern Table Styling */
.table-editable {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.75rem;
    border-collapse: separate;
    border-spacing: 0;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border-radius: 0.5rem;
    overflow: hidden;
    table-layout: fixed;
    width: 100% !important;
    margin: 0 !important;
}

.table-editable thead th {
    background: linear-gradient(135deg, #343a40 0%, #495057 100%);
    color: white;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 0.5rem;
    border: none;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-editable tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.table-editable tbody tr:hover {
    background-color: #f8f9fa;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

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

.table-editable td {
    padding: 0.6rem 0.5rem;
    vertical-align: middle;
    border: none;
    position: relative;
    font-size: 0.7rem;
}

/* Fixed width columns - first 7 columns for benchmark tables */
.table-editable th:nth-child(1), /* Channel */
.table-editable td:nth-child(1) {
    width: 170px;
    min-width: 170px;
    max-width: 170px;
    font-weight: 500;
}

.table-editable th:nth-child(2), /* Placement/Format */
.table-editable td:nth-child(2) {
    width: 170px;
    min-width: 170px;
    max-width: 170px;
}

.table-editable th:nth-child(3), /* Bid/Buying Model */
.table-editable td:nth-child(3) {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    text-align: center;
}

.table-editable th:nth-child(4), /* CPM/Budget */
.table-editable td:nth-child(4) {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    text-align: right;
}

.table-editable th:nth-child(5), /* CPV/CPC/Impressions */
.table-editable td:nth-child(5) {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    text-align: right;
}

.table-editable th:nth-child(6), /* Frequency */
.table-editable td:nth-child(6) {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    text-align: right;
}

.table-editable th:nth-child(7), /* Actions */
.table-editable td:nth-child(7) {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    text-align: center;
}

/* Dynamic width columns - distribute remaining space perfectly */
/* Fixed columns total: 170 + 130 + 80 + 130 = 510px */
/* Remaining space: calc(100% - 510px) must be distributed with NO leftover */

.table-editable th:nth-child(n+5), /* All columns from 5 onwards */
.table-editable td:nth-child(n+5) {
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* AWARENESS TABLE (8 columns total: 4 fixed + 4 dynamic) */
/* Impressions (30%) + CPM (20%) + Frequency (25%) + Reach (25%) = 100% */
.table-awareness th:nth-child(5), /* Impressions */
.table-awareness td:nth-child(5) {
    width: calc((100% - 510px) * 0.30);
}

.table-awareness th:nth-child(6), /* CPM */
.table-awareness td:nth-child(6) {
    width: calc((100% - 510px) * 0.20);
}

.table-awareness th:nth-child(7), /* Frequency */
.table-awareness td:nth-child(7) {
    width: calc((100% - 510px) * 0.25);
}

.table-awareness th:nth-child(8), /* Reach */
.table-awareness td:nth-child(8) {
    width: calc((100% - 510px) * 0.25);
}

/* CONSIDERATION TABLE (10 columns total: 4 fixed + 6 dynamic) */
/* Impressions (25%) + CPM (15%) + Video Views (25%) + CPV (15%) + Frequency (10%) + Reach (10%) = 100% */
.table-consideration th:nth-child(5), /* Impressions */
.table-consideration td:nth-child(5) {
    width: calc((100% - 510px) * 0.25);
}

.table-consideration th:nth-child(6), /* CPM */
.table-consideration td:nth-child(6) {
    width: calc((100% - 510px) * 0.15);
}

.table-consideration th:nth-child(7), /* Video Views */
.table-consideration td:nth-child(7) {
    width: calc((100% - 510px) * 0.25);
}

.table-consideration th:nth-child(8), /* CPV */
.table-consideration td:nth-child(8) {
    width: calc((100% - 510px) * 0.15);
}

.table-consideration th:nth-child(9), /* Frequency */
.table-consideration td:nth-child(9) {
    width: calc((100% - 510px) * 0.10);
}

.table-consideration th:nth-child(10), /* Reach */
.table-consideration td:nth-child(10) {
    width: calc((100% - 510px) * 0.10);
}

/* ACQUISITION TABLE (10 columns total: 4 fixed + 6 dynamic) */
/* Impressions (25%) + CPM (15%) + Clicks (25%) + CPC (15%) + Frequency (10%) + Reach (10%) = 100% */
.table-acquisition th:nth-child(5), /* Impressions */
.table-acquisition td:nth-child(5) {
    width: calc((100% - 510px) * 0.25);
}

.table-acquisition th:nth-child(6), /* CPM */
.table-acquisition td:nth-child(6) {
    width: calc((100% - 510px) * 0.15);
}

.table-acquisition th:nth-child(7), /* Clicks */
.table-acquisition td:nth-child(7) {
    width: calc((100% - 510px) * 0.25);
}

.table-acquisition th:nth-child(8), /* CPC */
.table-acquisition td:nth-child(8) {
    width: calc((100% - 510px) * 0.15);
}

.table-acquisition th:nth-child(9), /* Frequency */
.table-acquisition td:nth-child(9) {
    width: calc((100% - 510px) * 0.10);
}

.table-acquisition th:nth-child(10), /* Reach */
.table-acquisition td:nth-child(10) {
    width: calc((100% - 510px) * 0.10);
}

/* APP INSTALLS TABLE (10 columns total: 4 fixed + 6 dynamic) */
/* Impressions (25%) + CPM (15%) + Installs (25%) + CPI (15%) + Frequency (10%) + Reach (10%) = 100% */
.table-app_installs th:nth-child(5), /* Impressions */
.table-app_installs td:nth-child(5) {
    width: calc((100% - 510px) * 0.25);
}

.table-app_installs th:nth-child(6), /* CPM */
.table-app_installs td:nth-child(6) {
    width: calc((100% - 510px) * 0.15);
}

.table-app_installs th:nth-child(7), /* Installs */
.table-app_installs td:nth-child(7) {
    width: calc((100% - 510px) * 0.25);
}

.table-app_installs th:nth-child(8), /* CPI */
.table-app_installs td:nth-child(8) {
    width: calc((100% - 510px) * 0.15);
}

.table-app_installs th:nth-child(9), /* Frequency */
.table-app_installs td:nth-child(9) {
    width: calc((100% - 510px) * 0.10);
}

.table-app_installs th:nth-child(10), /* Reach */
.table-app_installs td:nth-child(10) {
    width: calc((100% - 510px) * 0.10);
}

/* Editable input styling */
.table-editable .editable {
    background: transparent;
    border: 2px solid transparent;
    width: 100%;
    text-align: inherit;
    padding: 0.25rem;
    border-radius: 0.25rem;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.table-editable .editable:focus {
    background: #fff;
    border-color: #0d6efd;
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.table-editable .editable:hover {
    background: rgba(13, 110, 253, 0.05);
}

/* Total row styling */
.table-editable tfoot tr {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-top: 2px solid #dee2e6;
}

.table-editable tfoot td {
    font-weight: 600;
    color: #495057;
    padding: 1rem 0.75rem;
}

/* Numerical value styling */
.text-end {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* Management fee and VAT rows */
.table-editable tfoot tr:nth-child(2),
.table-editable tfoot tr:nth-child(3) {
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.table-editable tfoot tr:nth-child(2) td,
.table-editable tfoot tr:nth-child(3) td {
    font-weight: 500;
    color: #6c757d;
    padding: 0.75rem;
}

/* Responsive table enhancements */
.table-responsive {
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Editable value styling */
.editable-value {
    cursor: pointer;
    padding: 0;
    border-radius: 0.25rem;
    transition: all 0.1s ease;
    border: 1px solid transparent;
    display: inline-block;
    text-align: inherit;
}

.editable-value:hover {
    background-color: #e3f2fd;
    border-color: #2196f3;
    box-shadow: 0 0 0 0.1rem rgba(33, 150, 243, 0.25);
    padding: 0.25rem 0.5rem;
}

/* Faster tooltip display */
[title] {
    position: relative;
}

.editable-value:active {
    background-color: #bbdefb;
}

/* Saudi Riyal symbol styling */
.sar-symbol {
    display: inline-block;
    width: 12px;
    height: 12px;
    vertical-align: middle;
    margin-right: 2px;
}

/* Saudi Riyal symbol in dark headers */
.table-dark .sar-symbol {
    filter: brightness(0) invert(1);
}

/* Compact modern table styling - higher specificity to override existing rules */
.table-editable thead.table-dark th {
    font-size: 0.7rem !important;
    font-weight: 600;
    white-space: nowrap;
    padding: 0.4rem !important;
}

.table-editable td, .table-editable th {
    font-size: 0.7rem !important;
    padding: 0.4rem !important;
    vertical-align: middle;
}

/* Prevent wrapping in first column (channel names) */
.table-editable td:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
}

/* Bootstrap tabs customization */
.nav-tabs .nav-link {
    border: none;
    border-radius: 0.5rem 0.5rem 0 0;
    margin-right: 0.25rem;
    color: #6c757d;
    font-weight: 500;
}

.nav-tabs .nav-link.active {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border: none;
}

.nav-tabs .nav-link:hover:not(.active) {
    background-color: #f8f9fa;
    color: #495057;
    border-color: transparent;
}

.navbar-brand {
    font-weight: bold;
}

.card {
    transition: box-shadow 0.15s ease-in-out;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.btn {
    transition: all 0.15s ease-in-out;
}

/* Editable benchmark cells */
.editable-cell {
    cursor: pointer;
    position: relative;
}

.editable-cell:hover {
    background-color: #f8f9fa;
}

.editable-value {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    transition: all 0.2s;
}

.editable-value:hover {
    background-color: #e9ecef;
    box-shadow: 0 0 0 1px #dee2e6;
}

.editable-value.editing {
    background-color: #fff3cd;
}

/* Campaign action buttons - responsive layout */
.campaign-actions-card .card-body {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.campaign-actions-card .btn,
.campaign-actions-card .btn-group {
    margin: 0 !important;
}

/* Dashboard cards - ensure equal height buttons */
.dashboard-card .card-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.dashboard-card .btn {
    width: 100%;
    max-width: 200px;
}

/* Responsive utilities */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: auto;
    }

    /* Dashboard cards responsive design */
    .dashboard-card .card-title {
        font-size: 1rem;
    }

    .dashboard-card .card-text {
        font-size: 0.85rem;
        margin-bottom: 1rem;
    }

    .dashboard-card .btn {
        font-size: 0.85rem;
        padding: 0.375rem 0.75rem;
    }

    .dashboard-card .fa-3x {
        font-size: 2rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* Campaign actions - stack vertically on tablets */
    .campaign-actions-card .card-body {
        flex-direction: column;
    }
    
    .campaign-actions-card .btn,
    .campaign-actions-card .btn-group {
        width: 100%;
    }
}

@media (max-width: 576px) {
    /* Extra small screens */
    .dashboard-card .card-title {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .dashboard-card .card-text {
        font-size: 0.75rem;
        margin-bottom: 0.75rem;
        display: none; /* Hide description text on very small screens */
    }

    .dashboard-card .btn {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }

    .dashboard-card .fa-3x {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    .dashboard-card .card-body {
        padding: 1rem 0.5rem;
    }
    
    /* Campaign actions - full width buttons on mobile */
    .campaign-actions-card .btn,
    .campaign-actions-card .btn-group {
        width: 100%;
    }
    
    .campaign-actions-card .btn-group .dropdown-toggle {
        width: 100%;
    }
}