:root {
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Auth Screen */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.auth-card {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.btn-google {
    background-color: #fff;
    color: #3c4043;
    border: 1px solid #dadce0;
    padding: 10px 24px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-google:hover {
    background-color: #f7f8f9;
    border-color: #d2e3fc;
}

/* Dashboard */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-select,
.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

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

/* Time Range Tags */
.range-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.range-tag {
    padding: 0.5rem 1rem;
    background: #f3f4f6;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.range-tag.active {
    background: var(--primary-color);
    color: white;
}

/* Page List */
.page-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.page-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    transition: background 0.1s;
}

.page-item:last-child {
    border-bottom: none;
}

.page-item:hover {
    background-color: #f9fafb;
}

.page-item.selected {
    background-color: #eff6ff;
    border-left: 4px solid var(--primary-color);
}

.page-url {
    font-weight: 500;
    color: var(--primary-color);
}

.page-metric {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Results Table */
.results-table {
    width: 100%;
    border-collapse: collapse;
}

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

.results-table th {
    background-color: #f9fafb;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.badge-zero {
    background-color: #fee2e2;
    color: #991b1b;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.75rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
}

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

.btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Loader */
.loader {
    border: 3px solid #f3f3f3;
    border-radius: 50%;
    border-top: 3px solid var(--primary-color);
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

    100% {
        transform: rotate(360deg);
    }
}


/* Action Report */
.action-box {
    margin-bottom: 2rem;
    padding: 1rem;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-report {
    background: #0ea5e9;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.btn-report:hover {
    background: #0284c7;
}

/* Checkbox specific */
input[type="checkbox"].save-toggle {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Modal for Report */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
}

.site-header-row td {
    position: sticky;
    top: 0;
    /* Ideally headers are sticky but simplified for table structure */
}

.btn-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-delete:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Custom Overrides */
.leading-tight {
    line-height: 2.25 !important;
}

.text-xs {
    font-size: 0.80rem !important;
}

/* PRINT STYLES - PDF REPORT FIXES */
@media print {
    @page {
        size: A4;
        margin: 5mm;
        /* Minimal margins */
    }

    body {
        background: white;
        color: black;
        font-size: 9pt !important;
        /* Scale down for print to fit width */
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Hide UI Elements */
    .sidebar,
    nav,
    header,
    .header-actions,
    button,
    .btn-report,
    .tabs,
    #view-settings,
    .btn-delete-row,
    .toggle-save {
        display: none !important;
    }

    /* Max Width for Content */
    .main-content,
    .dashboard-container {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        max-width: none !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    /* Force Grid Layouts */
    .grid {
        display: grid !important;
        width: 100% !important;
    }

    /* Force 3 Columns for Lists (Traffic, Top 3, Top 10) */
    .lg\:grid-cols-3 {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
    }

    /* Force 4 Columns for Stats */
    .lg\:grid-cols-4 {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
    }

    /* Force 2 Columns for Winners/Losers */
    .lg\:grid-cols-2 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    /* Adjust Card Paddings */
    .p-6 {
        padding: 0.75rem !important;
    }

    /* Fixed Height Container for Widgets to prevent overflow */
    .bg-white.rounded-xl {
        break-inside: avoid;
        border: 1px solid #eee !important;
        border-radius: 8px !important;
        /* height: auto !important; */
    }

    /* List Item Specifics (Fix Wrapping Shift) */
    #prListTraffic>div,
    #prListTop3>div,
    #prListTop10>div {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        padding: 2px 0 !important;
        /* Tighter padding */
    }

    /* Keyword and Metrics Sizing */
    /* Keyword text column */
    #prListTraffic>div>div:first-child,
    #prListTop3>div>div:first-child,
    #prListTop10>div>div:first-child {
        min-width: 0;
        flex: 1 1 auto;
        margin-right: 4px !important;
    }

    /* Keyword text truncate text */
    #prListTraffic .truncate,
    #prListTop3 .truncate,
    #prListTop10 .truncate {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        font-size: 8pt !important;
        max-width: 100% !important;
        display: block !important;
    }

    /* Metric column (Right side) */
    #prListTraffic>div>div:last-child,
    #prListTop3>div>div:last-child,
    #prListTop10>div>div:last-child {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
        text-align: right !important;
        width: auto !important;
    }

    /* Ensure text doesn't wrap in metric spans */
    .text-right span {
        white-space: nowrap !important;
    }

    /* Chart Scaling */
    canvas {
        max-height: 250px !important;
        /* Smaller chart height */
        width: 100% !important;
    }

    /* Table Fixes */
    table {
        width: 100% !important;
        font-size: 8pt !important;
        table-layout: fixed;
        /* Force fixed table layout */
    }

    th,
    td {
        padding: 2px 4px !important;
        word-wrap: break-word;
    }

    /* Page Break Logic */
    .dashboard-view {
        break-before: page;
        margin-top: 20px;
    }

    /* Prevent cutting inside elements */
    .bg-white,
    .card,
    .chart-container {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* Table Specifics */
    table {
        width: 100% !important;
        border-collapse: collapse;
    }

    tr {
        break-inside: avoid;
        page-break-inside: avoid;
        break-after: auto;
    }

    td,
    th {
        padding: 6px 8px !important;
        /* Smaller padding for print */
    }

    thead {
        display: table-header-group;
        /* Repeat header on new page */
    }

    tfoot {
        display: table-footer-group;
    }
}
}