﻿:root {
    --primary-color: #4285f4;
    --success-color: #34a853;
    --warning-color: #fbbc04;
    --danger-color: #ea4335;
}

/* Mobile Filter Button - Hidden on Desktop */
.mobile-filter-btn {
    display: none;
    position: relative;
    background: linear-gradient(135deg, #34a853 0%, #2d8f47 100%);
    color: white !important;
    border: none;
    padding: 10px 20px !important;
    border-radius: 8px !important;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
}

    .mobile-filter-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 5px 15px rgba(52, 168, 83, 0.4);
    }

    .mobile-filter-btn i {
        color: white;
    }

.filter-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ea4335;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}

/* Desktop Control Panel - Hidden on Mobile */
.desktop-only {
    display: block;
}

/* Filter Modal Overlay */
.filter-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

    .filter-modal-overlay.active {
        display: block;
        opacity: 1;
    }

/* Filter Modal (Bottom Sheet) */
.filter-modal {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    max-height: 80vh;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

    .filter-modal.active {
        display: block;
        transform: translateY(0);
    }

.filter-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 15px 20px;
    border-bottom: 2px solid #e5e7eb;
}

    .filter-modal-header h4 {
        margin: 0;
        font-size: 18px;
        font-weight: 700;
        color: #1f2937;
    }

.filter-close-btn {
    background: #f3f4f6;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .filter-close-btn:hover {
        background: #e5e7eb;
    }

    .filter-close-btn i {
        font-size: 16px;
        color: #6b7280;
    }

.filter-modal-body {
    padding: 20px;
    max-height: calc(80vh - 160px);
    overflow-y: auto;
}

.filter-group {
    margin-bottom: 20px;
}

    .filter-group:last-child {
        margin-bottom: 0;
    }

.filter-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 8px;
}

    .filter-label i {
        color: #667eea;
    }

.filter-modal-footer {
    display: flex;
    gap: 12px;
    padding: 15px 20px;
    border-top: 2px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 20px 20px;
}

.btn-clear {
    flex: 1;
    padding: 12px 20px;
    background: white;
    color: #6b7280;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .btn-clear:hover {
        background: #f3f4f6;
        border-color: #d1d5db;
    }

.btn-apply {
    flex: 2;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .btn-apply:hover {
        transform: translateY(-2px);
        box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
    }



.dashboard-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 15px;
}

.header-section {
    background: white;
    border-radius: 15px !important;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

    .header-section h1 {
        color: #1f2937;
        font-weight: 700;
        margin: 0;
        display: flex;
        align-items: center;
        gap: 15px;
    }

        .header-section h1 i {
            color: var(--primary-color);
        }

.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #6b7280;
}

    .sync-status .pulse {
        width: 8px;
        height: 8px;
        background: var(--success-color);
        border-radius: 50% !important;
        animation: pulse 2s infinite;
    }

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.metric-card {
    background: white;
    border-radius: 15px !important;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

    .metric-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 15px 35px rgba(0,0,0,0.15);
    }

    .metric-card .icon {
        width: 60px;
        height: 60px;
        border-radius: 12px !important;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 28px;
        margin-bottom: 15px;
    }

    .metric-card.primary .icon {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
    }

    .metric-card.success .icon {
        background: linear-gradient(135deg, #34a853 0%, #2d8f47 100%);
        color: white;
    }

    .metric-card.warning .icon {
        background: linear-gradient(135deg, #fbbc04 0%, #e6a800 100%);
        color: white;
    }

    .metric-card.danger .icon {
        background: linear-gradient(135deg, #ea4335 0%, #d33426 100%);
        color: white;
    }

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: #1f2937;
    margin: 10px 0 5px 0;
}

.metric-label {
    color: #6b7280;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.metric-change {
    font-size: 13px;
    margin-top: 8px;
}

    .metric-change.positive {
        color: var(--success-color);
    }

.control-panel {
    background: white;
    border-radius: 15px !important;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
}

.main-table-card {
    background: white;
    border-radius: 15px !important;
    padding: 25px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
    margin-bottom: 40px !important;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e5e7eb;
}

    .table-header h3 {
        margin: 0;
        color: #1f2937;
        font-weight: 600;
    }

.table-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.export-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    border: none;
    padding: 10px 20px !important;
    border-radius: 8px !important;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
}

    .export-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
    }

.custom-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

    .custom-table thead th {
        background: #f9fafb;
        color: #374151;
        font-weight: 600;
        border: none;
        padding: 15px;
        text-transform: uppercase;
        font-size: 12px;
        letter-spacing: 0.5px;
        cursor: pointer;
        user-select: none;
    }

        .custom-table thead th:hover {
            background: #f3f4f6;
        }

        .custom-table thead th:first-child {
            border-radius: 8px 0 0 8px !important;
        }

        .custom-table thead th:last-child {
            border-radius: 0 8px 8px 0 !important;
        }

    .custom-table tbody tr {
        background: white;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
        transition: all 0.3s ease;
    }

        .custom-table tbody tr:hover {
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
            transform: translateY(-2px);
        }

    .custom-table tbody td {
        padding: 15px;
        vertical-align: middle;
        border: none;
    }

        .custom-table tbody td:first-child {
            border-radius: 8px 0 0 8px !important;
        }

        .custom-table tbody td:last-child {
            border-radius: 0 8px 8px 0 !important;
        }

.keyword-text {
    font-weight: 600;
    color: #1f2937;
}

.badge-difficulty {
    padding: 6px 12px;
    border-radius: 20px !important;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

    .badge-difficulty.easy {
        background: #d1fae5;
        color: #065f46;
    }

    .badge-difficulty.medium {
        background: #fef3c7;
        color: #92400e;
    }

    .badge-difficulty.hard {
        background: #fee2e2;
        color: #991b1b;
    }

.trend-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 6px !important;
    font-size: 12px;
    font-weight: 600;
}

    .trend-indicator.up {
        background: #d1fae5;
        color: #065f46;
    }

    .trend-indicator.down {
        background: #fee2e2;
        color: #991b1b;
    }

    .trend-indicator.stable {
        background: #e5e7eb;
        color: #374151;
    }

.competition-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px !important;
    overflow: hidden;
}

.competition-fill {
    height: 100%;
    transition: width 0.3s ease;
}

    .competition-fill.low {
        background: linear-gradient(90deg, #34a853 0%, #2d8f47 100%);
    }

    .competition-fill.medium {
        background: linear-gradient(90deg, #fbbc04 0%, #e6a800 100%);
    }

    .competition-fill.high {
        background: linear-gradient(90deg, #ea4335 0%, #d33426 100%);
    }

.chart-container {
    background: white;
    border-radius: 15px !important;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
}

    .chart-container h4 {
        margin-bottom: 20px;
        color: #1f2937;
        font-weight: 600;
    }

.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
}

    .pagination button {
        padding: 8px 12px;
        border: 1px solid #e5e7eb;
        background: white;
        border-radius: 6px !important;
        cursor: pointer;
        transition: all 0.3s ease;
    }

        .pagination button:hover:not(:disabled) {
            background: #667eea;
            color: white;
            border-color: #667eea;
        }

        .pagination button.active {
            background: #667eea;
            color: white;
            border-color: #667eea;
        }

        .pagination button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

@media (max-width: 768px) {
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}


/* Keep all your existing styles */

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.loading-content {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 20px !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #f3f4f6;
    border-top: 5px solid #667eea;
    border-radius: 50% !important;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    color: #1f2937;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

.loading-subtext {
    color: #6b7280;
    font-size: 14px;
}

/* Empty state styles */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

    .empty-state i {
        font-size: 64px;
        color: #d1d5db;
        margin-bottom: 20px;
    }

    .empty-state h4 {
        color: #374151;
        font-weight: 600;
        margin-bottom: 10px;
    }

    .empty-state p {
        color: #6b7280;
        margin-bottom: 0;
    }



/* Mobile - 2 Cards Per Row Layout */
@media (max-width: 768px) {
    /* Container */
    .container-fluid {
        padding: 0 !important;
    }

    .page-header {
        padding: 0 !important;
    }

    .dashboard-container {
        max-width: 100%;
        padding: 0 10px;
    }

    /* Header */
    .main-header {
        padding: 12px 15px !important;
        background: white;
        box-shadow: 0 2px 4px rgba(0,0,0,0.06);
        margin-bottom: 12px;
        border-radius: 0 !important;
    }

        .main-header h2 {
            font-size: 18px !important;
            margin: 0;
        }

    #refreshData i {
        font-size: 18px !important;
    }

    /* 2 CARDS PER ROW - This is the key change */
    .row {
        margin: 0 -6px;
    }

    .col-xl-3,
    .col-md-6 {
        width: 50% !important;
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 0 6px !important;
    }

    /* Compact Metric Cards */
    .metric-card {
        padding: 14px 12px;
        margin-bottom: 12px;
        border-radius: 10px !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }

        .metric-card:hover {
            transform: none;
            box-shadow: 0 2px 8px rgba(0,0,0,0.06);
        }

        .metric-card .icon {
            width: 40px;
            height: 40px;
            font-size: 18px;
            margin-bottom: 8px;
            border-radius: 8px !important;
        }

    .metric-value {
        font-size: 22px !important;
        font-weight: 700;
        margin: 6px 0 4px 0;
        line-height: 1.2;
    }

    .metric-label {
        font-size: 9px !important;
        letter-spacing: 0.3px;
        font-weight: 700;
        line-height: 1.3;
    }

    .metric-change {
        font-size: 9px !important;
        margin-top: 6px;
        line-height: 1.3;
    }

        .metric-change i {
            font-size: 8px;
        }

        .metric-change span {
            font-weight: 600;
        }

    /* Table Card */
    .main-table-card {
        padding: 14px 10px;
        margin-bottom: 20px !important;
        border-radius: 10px !important;
    }

    .table-header {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        margin-bottom: 14px;
        padding-bottom: 10px;
    }

        .table-header h3 {
            font-size: 15px !important;
            margin: 0;
            width: 100%;
        }

            .table-header h3 i {
                font-size: 15px;
            }

    .table-actions {
        display: flex;
        gap: 8px;
        align-items: center;
        width: 100%;
        justify-content: flex-end;
    }

    /* MOBILE FILTER BUTTON - Show on mobile */
    .mobile-filter-btn {
        display: inline-block !important;
        padding: 7px 12px !important;
        font-size: 12px !important;
        min-height: 34px;
        white-space: nowrap;
        border-radius: 7px !important;
    }

        .mobile-filter-btn i {
            font-size: 11px;
            margin-right: 4px !important;
        }

    .export-btn {
        padding: 7px 12px !important;
        font-size: 12px !important;
        min-height: 34px;
        width: auto !important;
        white-space: nowrap;
        border-radius: 7px !important;
    }

        .export-btn i {
            font-size: 11px;
            margin-right: 4px !important;
        }

    /* Table - IMPORTANT SCROLLING */
    .table-responsive {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 -10px !important;
        padding: 0 10px !important;
        scroll-behavior: smooth !important;
    }

    .custom-table {
        min-width: 850px !important;
        font-size: 12px;
        border-spacing: 0 5px;
    }

        .custom-table thead th {
            padding: 9px 7px !important;
            font-size: 9px !important;
            font-weight: 700 !important;
            background: #f9fafb;
            position: sticky;
            top: 0;
            z-index: 10;
        }

            .custom-table thead th:first-child {
                border-radius: 8px 0 0 8px !important;
            }

            .custom-table thead th:last-child {
                border-radius: 0 8px 8px 0 !important;
            }

        .custom-table tbody tr {
            border-radius: 8px !important;
        }

        .custom-table tbody td {
            padding: 10px 7px !important;
            font-size: 12px !important;
        }

            .custom-table tbody td:first-child {
                border-radius: 8px 0 0 8px !important;
            }

            .custom-table tbody td:last-child {
                border-radius: 0 8px 8px 0 !important;
            }

    .keyword-text {
        font-size: 13px !important;
        font-weight: 600;
        display: block;
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .badge-difficulty {
        padding: 3px 7px !important;
        font-size: 9px !important;
        border-radius: 10px !important;
    }

    .trend-indicator {
        padding: 3px 7px !important;
        font-size: 10px !important;
        gap: 3px;
        border-radius: 5px !important;
    }

        .trend-indicator i {
            font-size: 9px;
        }

    .competition-bar {
        height: 5px;
        margin-bottom: 3px;
        border-radius: 3px !important;
    }

    .custom-table tbody td small {
        font-size: 10px !important;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 5px;
        margin-top: 14px;
    }

        .pagination button {
            padding: 7px 11px !important;
            font-size: 12px !important;
            min-width: 36px;
            min-height: 36px;
            border-radius: 6px !important;
        }

            .pagination button i {
                font-size: 11px;
            }

    /* Loading Overlay */
    .loading-overlay {
        position: fixed;
    }

    .loading-content {
        padding: 25px 18px;
        margin: 0 20px;
        border-radius: 14px !important;
    }

    .spinner {
        width: 45px;
        height: 45px;
        border-width: 4px;
    }

    .loading-text {
        font-size: 15px !important;
    }

    .loading-subtext {
        font-size: 12px !important;
    }

    /* Empty State */
    .empty-state {
        padding: 35px 18px;
    }

        .empty-state i {
            font-size: 44px;
        }

        .empty-state h4 {
            font-size: 15px !important;
        }

        .empty-state p {
            font-size: 12px !important;
        }
}

/* Small Mobile (≤ 420px) - Even more compact */
@media (max-width: 420px) {
    .dashboard-container {
        padding: 0 8px;
    }

    .row {
        margin: 0 -5px;
    }

    .col-xl-3,
    .col-md-6 {
        padding: 0 5px !important;
    }

    .metric-card {
        padding: 12px 10px;
        margin-bottom: 10px;
        border-radius: 10px !important;
    }

        .metric-card .icon {
            width: 36px;
            height: 36px;
            font-size: 16px;
            border-radius: 8px !important;
        }

    .metric-value {
        font-size: 20px !important;
    }

    .metric-label {
        font-size: 8px !important;
    }

    .metric-change {
        font-size: 8px !important;
    }

    .main-table-card {
        padding: 12px 8px;
        border-radius: 10px !important;
    }

    .table-header h3 {
        font-size: 14px !important;
    }

    .export-btn {
        padding: 6px 10px !important;
        font-size: 11px !important;
        border-radius: 7px !important;
    }

    .custom-table {
        min-width: 800px !important;
    }

    .pagination button {
        border-radius: 6px !important;
    }
}

/* Landscape orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .metric-card {
        padding: 10px 8px;
        margin-bottom: 8px;
        border-radius: 8px !important;
    }

        .metric-card .icon {
            width: 32px;
            height: 32px;
            font-size: 14px;
            margin-bottom: 4px;
            border-radius: 6px !important;
        }

    .metric-value {
        font-size: 18px !important;
    }

    .metric-label {
        font-size: 8px !important;
    }

    .metric-change {
        font-size: 8px !important;
        margin-top: 4px;
    }
}

/* Fix for iOS Safari and Samsung Internet */
@supports (-webkit-touch-callout: none) {
    .table-responsive {
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: smooth !important;
    }

    .custom-table tbody tr:hover {
        transform: none;
    }
}


/* Fix for mobile page scrolling */
@media (max-width: 768px) {
    /* Allow page to scroll vertically */
    html, body {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100vh !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .container-fluid {
        padding: 0 !important;
        overflow-x: hidden !important;
        min-height: 100vh !important;
    }

    .page-header {
        padding: 0 !important;
        overflow: visible !important;
    }

    .dashboard-container {
        max-width: 100%;
        padding: 0 10px;
        overflow: visible !important;
        min-height: 100vh !important;
    }

    /* Header - Make it sticky at top */
    .main-header {
        padding: 12px 15px !important;
        background: white;
        box-shadow: 0 2px 4px rgba(0,0,0,0.06);
        margin-bottom: 12px;
        border-radius: 0 !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 100 !important;
    }

        .main-header h2 {
            font-size: 18px !important;
            margin: 0;
        }

    #refreshData i {
        font-size: 18px !important;
    }

    /* Table Card - Allow vertical scrolling on page */
    .main-table-card {
        padding: 14px 10px;
        margin-bottom: 20px !important;
        border-radius: 10px !important;
        overflow: visible !important;
    }

    /* Table - Horizontal scroll only, page scrolls vertically */
    .table-responsive {
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 -10px !important;
        padding: 0 10px !important;
        scroll-behavior: smooth !important;
        position: relative !important;
    }

    .custom-table {
        min-width: 850px !important;
        font-size: 12px;
        border-spacing: 0 5px;
        margin-bottom: 0 !important;
    }

    /* Add padding at bottom for pagination visibility */
    .dashboard-container {
        padding-bottom: 30px !important;
    }

    /* Hide desktop control panel */
    .desktop-only {
        display: none !important;
    }
}
