/* Main CSS Entry Point for NewsMonitor */
/* This file imports all other CSS files in the correct order and includes global styles */

/* ===== THEME IMPORTS ===== */
/* Import theme files first to establish CSS variables */
@import url('./themes/common.css');
@import url('./themes/light.css');
@import url('./themes/dark.css');

/* ===== CORE COMPONENT IMPORTS ===== */
/* Import component styles in dependency order */
@import url('./components/layout.css');
@import url('./components/forms.css');
@import url('./components/buttons.css');
@import url('./components/cards.css');
@import url('./components/modals.css');
@import url('./components/tables.css');
@import url('./components/avatars.css');
@import url('./components/posts.css');
@import url('./components/lists.css');
@import url('./components/widgets.css');
@import url('./components/alerts.css');
@import url('./components/badges.css');


/* ===== FEATURE-SPECIFIC IMPORTS ===== */
/* Import remaining feature-specific CSS files that haven't been migrated */
@import url('./admin.css');

/* ===== GLOBAL STYLES AND RESETS ===== */

/* CSS Reset and Normalization */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Remove default margins and paddings */
* {
    margin: 0;
    padding: 0;
}

/* Improve text rendering */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Improve media defaults */
img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Remove built-in form typography styles */
input,
button,
textarea,
select {
    font: inherit;
}

/* Avoid text overflows */
p,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Improve line heights */
h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1.2;
}

p {
    line-height: 1.6;
}

/* Remove list styles where appropriate */
ul,
ol {
    list-style: none;
}

/* Remove button styles */
button {
    background: none;
    border: none;
    cursor: pointer;
}

/* Improve focus visibility */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ===== GLOBAL UTILITY CLASSES ===== */

/* Flexbox utilities */
.d-flex {
    display: flex !important;
}

.flex-column {
    flex-direction: column !important;
}

.flex-row {
    flex-direction: row !important;
}

.justify-content-center {
    justify-content: center !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.align-items-center {
    align-items: center !important;
}

.flex-grow-1 {
    flex-grow: 1 !important;
}

/* Spacing utilities */
.m-0 { margin: 0 !important; }
.m-1 { margin: var(--spacing-xs) !important; }
.m-2 { margin: var(--spacing-sm) !important; }
.m-3 { margin: var(--spacing-md) !important; }
.m-4 { margin: var(--spacing-lg) !important; }
.m-5 { margin: var(--spacing-xl) !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: var(--spacing-xs) !important; }
.p-2 { padding: var(--spacing-sm) !important; }
.p-3 { padding: var(--spacing-md) !important; }
.p-4 { padding: var(--spacing-lg) !important; }
.p-5 { padding: var(--spacing-xl) !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--spacing-xs) !important; }
.mb-2 { margin-bottom: var(--spacing-sm) !important; }
.mb-3 { margin-bottom: var(--spacing-md) !important; }
.mb-4 { margin-bottom: var(--spacing-lg) !important; }
.mb-5 { margin-bottom: var(--spacing-xl) !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--spacing-xs) !important; }
.mt-2 { margin-top: var(--spacing-sm) !important; }
.mt-3 { margin-top: var(--spacing-md) !important; }
.mt-4 { margin-top: var(--spacing-lg) !important; }
.mt-5 { margin-top: var(--spacing-xl) !important; }

.ms-1 { margin-left: var(--spacing-xs) !important; }
.ms-2 { margin-left: var(--spacing-sm) !important; }
.ms-3 { margin-left: var(--spacing-md) !important; }

.me-1 { margin-right: var(--spacing-xs) !important; }
.me-2 { margin-right: var(--spacing-sm) !important; }
.me-3 { margin-right: var(--spacing-md) !important; }

/* Display utilities */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }

/* Text utilities */
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.fw-normal { font-weight: normal !important; }
.fw-bold { font-weight: bold !important; }
.fw-light { font-weight: 300 !important; }

.fs-1 { font-size: 2.5rem !important; }
.fs-2 { font-size: 2rem !important; }
.fs-3 { font-size: 1.75rem !important; }
.fs-4 { font-size: 1.5rem !important; }
.fs-5 { font-size: 1.25rem !important; }
.fs-6 { font-size: 1rem !important; }

.small { font-size: 0.875rem !important; }

/* Border utilities */
.border { border: 1px solid var(--border-color) !important; }
.border-0 { border: 0 !important; }
.border-top { border-top: 1px solid var(--border-color) !important; }
.border-bottom { border-bottom: 1px solid var(--border-color) !important; }
.border-start { border-left: 4px solid var(--border-color) !important; }

.rounded { border-radius: var(--border-radius) !important; }
.rounded-0 { border-radius: 0 !important; }
.rounded-circle { border-radius: 50% !important; }

/* Shadow utilities */
.shadow-sm { box-shadow: 0 1px 3px var(--shadow-light) !important; }
.shadow { box-shadow: var(--shadow-hover) !important; }
.shadow-lg { box-shadow: 0 10px 25px var(--shadow-dark) !important; }

/* Position utilities */
.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.position-fixed { position: fixed !important; }

/* Width and height utilities */
.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

/* Overflow utilities */
.overflow-hidden { overflow: hidden !important; }
.overflow-auto { overflow: auto !important; }

/* ===== ADDITIONAL COLOR UTILITIES ===== */
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }

.bg-primary { background-color: var(--primary-color) !important; }
.bg-secondary { background-color: var(--bg-secondary) !important; }
.bg-success { background-color: var(--success-color) !important; }
.bg-danger { background-color: var(--danger-color) !important; }
.bg-warning { background-color: var(--warning-color) !important; }
.bg-info { background-color: var(--info-color) !important; }

.border-primary { border-color: var(--primary-color) !important; }
.border-success { border-color: var(--success-color) !important; }
.border-danger { border-color: var(--danger-color) !important; }
.border-warning { border-color: var(--warning-color) !important; }
.border-info { border-color: var(--info-color) !important; }

/* ===== GLOBAL ELEMENT STYLES ===== */
/* Links */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

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

/* Paragraphs and text */
p, span, div {
    color: var(--text-primary);
}

/* Highlight styles for matched keywords */
mark {
    background-color: var(--news-highlight);
    color: var(--news-highlight-text);
    padding: 0.1em 0.2em;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
}

/* ===== BOOTSTRAP COMPONENT OVERRIDES ===== */
/* Progress Bars */
.progress {
    background-color: var(--bg-tertiary) !important;
}

/* Tooltips and Popovers */
.tooltip-inner {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

.popover {
    background-color: var(--card-bg) !important;
    border-color: var(--border-color) !important;
}

.popover-header {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

.popover-body {
    color: var(--text-primary) !important;
}

/* ===== ACCESSIBILITY UTILITIES ===== */
/* Screen reader only content */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ===== DISPLAY UTILITIES ===== */
/* Show/Hide utilities */
.show { display: block !important; }
.hide { display: none !important; }

/* Visibility utilities */
.visible { visibility: visible !important; }
.invisible { visibility: hidden !important; }

/* ===== STATE UTILITIES ===== */
/* Active state utility - components can override this */

/* Disabled state utility */
.disabled {
    pointer-events: none !important;
    opacity: 0.6 !important;
    cursor: not-allowed !important;
}

/* ===== LAYOUT UTILITIES ===== */
/* Position utilities (additional ones) */
.position-sticky { position: sticky !important; }

/* Z-index utilities */
.z-index-1 { z-index: 1 !important; }
.z-index-10 { z-index: 10 !important; }
.z-index-100 { z-index: 100 !important; }
.z-index-1000 { z-index: 1000 !important; }

/* Additional width utilities */
.w-25 { width: 25% !important; }
.w-50 { width: 50% !important; }
.w-75 { width: 75% !important; }

/* Additional height utilities */
.h-25 { height: 25% !important; }
.h-50 { height: 50% !important; }
.h-75 { height: 75% !important; }

/* Additional border utilities */
.border-left { border-left: 1px solid var(--border-color) !important; }
.border-right { border-right: 1px solid var(--border-color) !important; }

/* Additional rounded utilities */
.rounded-sm { border-radius: var(--border-radius-sm) !important; }
.rounded-lg { border-radius: var(--border-radius-lg) !important; }

/* ===== RESPONSIVE UTILITIES ===== */
@media (max-width: 768px) {
    .d-md-none { display: none !important; }
    .d-md-block { display: block !important; }
    .text-md-center { text-align: center !important; }
}

/* ===== GLOBAL ANIMATIONS ===== */

/* Fade in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

/* Slide in animation */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.4s ease forwards;
}

/* Pulse animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Highlight animation for refreshed content */
@keyframes highlight-background {
    0% {
        background-color: var(--success-light);
    }
    100% {
        background-color: transparent;
    }
}

.highlight-refresh {
    animation: highlight-background 2s ease-out;
}

/* ===== GLOBAL RESPONSIVE UTILITIES ===== */

/* Hide/show elements based on screen size */
@media (max-width: 767.98px) {
    .d-md-none { display: none !important; }
    .d-md-block { display: block !important; }
}

@media (min-width: 768px) {
    .d-md-flex { display: flex !important; }
}

@media (max-width: 575.98px) {
    .d-sm-none { display: none !important; }
}

/* ===== PRINT STYLES ===== */
@media print {
    /* Hide interactive elements */
    .btn,
    .navbar,
    .footer,
    .dropdown,
    .modal {
        display: none !important;
    }
    
    /* Optimize text for print */
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
        background: #fff;
    }
    
    /* Ensure good contrast */
    .card {
        border: 1px solid #000;
        background: #fff;
    }
    
    /* Page breaks */
    .card,
    .json-renderer-item {
        page-break-inside: avoid;
    }

    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }

    /* Dynamic JSON Renderer print styles */
    .json-renderer-item {
        background-color: transparent !important;
        border-left: 2px solid #000;
    }

    .json-renderer-content a {
        color: #000 !important;
        text-decoration: underline !important;
    }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card,
    .btn,
    .form-control {
        border-width: 2px;
    }
}

/* Focus management for keyboard users */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: var(--text-inverse);
    padding: 8px;
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    z-index: 9999;
}

.skip-link:focus {
    top: 6px;
}

/* Ensure minimum touch target size */
@media (pointer: coarse) {
    .btn,
    .form-control,
    .dropdown-toggle,
    .nav-link {
        min-height: 30px;
        min-width: 30px;
    }
}
