/* Cross-Browser Compatibility Fixes for PDGM Lookup Tool */

/* Reset and normalize styles across browsers */
* {
    box-sizing: border-box;
}

*::before,
*::after {
    box-sizing: border-box;
}

/* Fix for Edge/IE flexbox issues */
.dashboard-container,
.dashboard-header,
.dashboard-actions,
.linking-actions,
.analytics-grid,
.metric-card,
.chart-container {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
}

.dashboard-header {
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
}

.dashboard-actions {
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 12px;
}

/* Fix for Edge button styling */
.btn,
.btn-primary,
.btn-secondary,
.nav-button,
button {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    padding: 8px 16px;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

/* Fix for Edge input styling */
input,
textarea,
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    padding: 8px 12px;
    width: 100%;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Analytics Dashboard Specific Fixes */
.analytics-dashboard {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

.internal-linking-section {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 24px;
    padding: 20px;
}

.linking-actions {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
}

.linking-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: inherit;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 12px;
    padding: 16px;
    text-decoration: none;
    transition: all 0.2s ease;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
    min-width: 200px;
}

.linking-card:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.card-icon {
    font-size: 1.5rem;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.card-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: #1f2937;
}

.card-content p {
    color: #6b7280;
    font-size: 0.875rem;
    margin: 0;
}

/* Metrics Grid Fixes */
.metrics-grid {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 32px;
}

.metric-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
    min-width: 200px;
    text-align: center;
}

.metric-value {
    color: #1f2937;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 8px;
}

.metric-label {
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
}

.metric-change {
    font-size: 0.75rem;
    margin-top: 4px;
}

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

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

/* Charts Container Fixes */
.charts-section {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    gap: 24px;
    margin-bottom: 32px;
}

.chart-container {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
    min-width: 300px;
}

.chart-title {
    color: #1f2937;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 16px;
}

/* Table Fixes for Edge */
.data-table {
    border-collapse: collapse;
    width: 100%;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid #f3f4f6;
    padding: 12px 16px;
    text-align: left;
}

.data-table th {
    background: #f8fafc;
    color: #374151;
    font-weight: 600;
    font-size: 0.875rem;
}

.data-table td {
    color: #1f2937;
    font-size: 0.875rem;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Form Fixes */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    color: #374151;
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
}

.form-input {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #1f2937;
    font-size: 0.875rem;
    line-height: 1.5;
    padding: 8px 12px;
    width: 100%;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

.form-input::placeholder {
    color: #9ca3af;
}

/* Edge-specific fixes */
@supports (-ms-ime-align: auto) {
    .dashboard-container {
        display: -ms-flexbox;
    }
    
    .dashboard-header {
        -ms-flex-pack: justify;
        -ms-flex-align: center;
    }
    
    .linking-actions {
        -ms-flex-wrap: wrap;
    }
    
    .linking-card {
        -ms-flex: 1 1 200px;
    }
    
    .metrics-grid {
        -ms-flex-wrap: wrap;
    }
    
    .metric-card {
        -ms-flex: 1 1 200px;
    }
}

/* Safari-specific fixes */
@supports (-webkit-appearance: none) {
    .btn,
    .nav-button,
    button {
        -webkit-appearance: none;
    }
    
    input,
    textarea,
    select {
        -webkit-appearance: none;
    }
    
    .linking-card:hover {
        -webkit-transform: translateY(-1px);
        transform: translateY(-1px);
    }
}

/* Firefox-specific fixes */
@-moz-document url-prefix() {
    .btn,
    .nav-button,
    button {
        -moz-appearance: none;
    }
    
    input,
    textarea,
    select {
        -moz-appearance: none;
    }
    
    .form-input:focus {
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }
}

/* Mobile responsiveness fixes */
@media (max-width: 768px) {
    .dashboard-header {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -webkit-flex-direction: column;
        -ms-flex-direction: column;
        flex-direction: column;
        gap: 16px;
        -webkit-box-align: stretch;
        -webkit-align-items: stretch;
        -ms-flex-align: stretch;
        align-items: stretch;
    }
    
    .dashboard-actions {
        -webkit-box-pack: center;
        -webkit-justify-content: center;
        -ms-flex-pack: center;
        justify-content: center;
        -webkit-flex-wrap: wrap;
        -ms-flex-wrap: wrap;
        flex-wrap: wrap;
    }
    
    .linking-actions {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -webkit-flex-direction: column;
        -ms-flex-direction: column;
        flex-direction: column;
    }
    
    .linking-card {
        min-width: auto;
    }
    
    .metrics-grid {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -webkit-flex-direction: column;
        -ms-flex-direction: column;
        flex-direction: column;
    }
    
    .metric-card {
        min-width: auto;
    }
    
    .charts-section {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -webkit-flex-direction: column;
        -ms-flex-direction: column;
        flex-direction: column;
    }
    
    .chart-container {
        min-width: auto;
    }
}

/* High DPI display fixes */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .metric-card,
    .chart-container,
    .linking-card {
        border-width: 0.5px;
    }
}

/* Print styles */
@media print {
    .dashboard-actions,
    .nav-button,
    button {
        display: none;
    }
    
    .dashboard-container {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .metric-card,
    .chart-container {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

