/* ========================================================
   Tax Scout PL — QuickMap-inspired design
   ======================================================== */

/* --- CSS Variables --- */
:root {
    --nav-bg: #1a2332;
    --nav-bg-hover: #243044;
    --page-bg: #f5f7fa;
    --surface: #ffffff;
    --text: #1a2332;
    --text-secondary: #5f6368;
    --text-muted: #8c939a;
    --border: #e1e5ea;
    --border-light: #eef1f5;

    /* Accents */
    --blue: #2196F3;
    --blue-dark: #1976D2;
    --blue-light: #e3f2fd;
    --green: #4CAF50;
    --green-light: #e8f5e9;
    --orange: #FF9800;
    --orange-light: #fff3e0;
    --red: #f44336;
    --red-light: #ffebee;
    --purple: #9C27B0;
    --purple-light: #f3e5f5;
    --yellow: #FFC107;
    --yellow-light: #fff8e1;
    --gray: #78909C;
    --gray-light: #eceff1;
    --dark: #37474F;

    --radius: 10px;
    --radius-sm: 6px;
    --radius-tag: 14px;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-card-hover: 0 4px 12px rgba(0,0,0,0.12);
    --shadow-modal: 0 8px 40px rgba(0,0,0,0.25);
    --transition: 0.2s ease;

    --grid-gap: 20px;
    --content-max: 1320px;
    --content-pad: 24px;
}

/* --- Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--page-bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ========================================
   TOP BAR / HEADER
   ======================================== */
.top-bar {
    background: var(--nav-bg);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.top-bar-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--content-pad);
    height: 60px;
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
    flex-shrink: 0;
}

.logo:hover {
    text-decoration: none;
}

.logo-icon {
    color: var(--green);
    font-size: 1.4rem;
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.logo-pl {
    color: var(--blue);
    font-weight: 800;
}

/* Search in header */
.search-wrapper {
    flex: 1;
    max-width: 480px;
}

.search-box {
    width: 100%;
    padding: 9px 16px;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
    background: rgba(255,255,255,0.12);
    color: #fff;
    outline: none;
    transition: background var(--transition);
}

.search-box::placeholder {
    color: rgba(255,255,255,0.5);
}

.search-box:focus {
    background: rgba(255,255,255,0.22);
}

/* Nav links */
.nav-links {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.nav-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}

.nav-link:hover,
.nav-link.active {
    background: var(--nav-bg-hover);
    color: #fff;
    text-decoration: none;
}

.nav-urgent {
    background: var(--red);
    color: #fff;
    font-weight: 600;
}

.nav-urgent:hover {
    background: #d32f2f;
}

/* ========================================
   MAIN CONTENT AREA
   ======================================== */
.main-content {
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
    padding: 20px var(--content-pad) 40px;
    flex: 1;
}

/* ========================================
   FILTERS SECTION
   ======================================== */
.filters-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.filters-row {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 4px;
}

/* Filter tags / pills */
.filter-tag {
    display: inline-block;
    padding: 5px 14px;
    border-radius: var(--radius-tag);
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1.3;
}

.filter-tag:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.filter-tag.active {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}

/* Source tag colours (when active) */
.filter-tag.tag-google.active { background: var(--blue); border-color: var(--blue); }
.filter-tag.tag-twitter.active { background: var(--dark); border-color: var(--dark); }
.filter-tag.tag-lex.active { background: var(--purple); border-color: var(--purple); }
.filter-tag.tag-mf.active { background: var(--green); border-color: var(--green); }

/* Category tag colours (when active) */
.filter-tag.tag-cit.active { background: var(--blue); border-color: var(--blue); }
.filter-tag.tag-pit.active { background: var(--green); border-color: var(--green); }
.filter-tag.tag-vat.active { background: var(--orange); border-color: var(--orange); }
.filter-tag.tag-ksef.active { background: var(--red); border-color: var(--red); }
.filter-tag.tag-zus.active { background: var(--purple); border-color: var(--purple); }
.filter-tag.tag-inne.active { background: var(--gray); border-color: var(--gray); }

/* Sort row */
.sort-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
}

.sort-btn {
    padding: 5px 14px;
    border-radius: var(--radius-tag);
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.sort-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.sort-btn.active {
    background: var(--nav-bg);
    color: #fff;
    border-color: var(--nav-bg);
}

.results-count {
    margin-left: auto;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ========================================
   NEWS FEED (vertical list)
   ======================================== */
.news-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 900px;
    margin: 0 auto;
}

/* ========================================
   NEWS CARD — horizontal feed row
   ======================================== */
.news-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: row;
    align-items: stretch;
    cursor: pointer;
    transition: box-shadow var(--transition), background var(--transition);
    position: relative;
    overflow: hidden;
}

.news-card:hover {
    box-shadow: var(--shadow-card-hover);
    background: #f8fafd;
}

/* Urgency 9-10: red-tinted background */
.news-card.card-critical {
    background: #fff5f5;
}
.news-card.card-critical:hover {
    background: #ffecec;
}

/* Left urgency color strip */
.card-urgency-strip {
    width: 4px;
    flex-shrink: 0;
    border-radius: var(--radius) 0 0 var(--radius);
}
.strip-green { background: var(--green); }
.strip-yellow { background: var(--yellow); }
.strip-orange { background: var(--orange); }
.strip-red { background: var(--red); }

/* Card body (middle section) */
.card-body {
    flex: 1;
    min-width: 0;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Tags row inside card */
.card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: var(--radius-tag);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.4;
}

/* Source tags */
.tag-source-google { background: var(--blue-light); color: var(--blue-dark); }
.tag-source-twitter { background: #263238; color: #fff; }
.tag-source-lex { background: var(--purple-light); color: var(--purple); }
.tag-source-mf { background: var(--green-light); color: #2E7D32; }
.tag-source-other { background: var(--gray-light); color: var(--gray); }

/* Category tags */
.tag-cat-cit { background: var(--blue-light); color: var(--blue-dark); }
.tag-cat-pit { background: var(--green-light); color: #2E7D32; }
.tag-cat-vat { background: var(--orange-light); color: #E65100; }
.tag-cat-ksef { background: var(--red-light); color: #C62828; }
.tag-cat-zus { background: var(--purple-light); color: var(--purple); }
.tag-cat-inne { background: var(--gray-light); color: var(--gray); }

/* Card headline */
.card-title {
    font-size: 0.93rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
}

/* Details preview — max 2 lines */
.card-details {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Right side: date + urgency badge */
.card-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 16px;
    flex-shrink: 0;
    min-width: 80px;
    border-left: 1px solid var(--border-light);
}

.card-date {
    font-size: 0.74rem;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
}

/* Urgency badge */
.urgency-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.urgency-low { background: var(--green-light); color: #2E7D32; }
.urgency-mid { background: var(--yellow-light); color: #F57F17; }
.urgency-high { background: var(--orange-light); color: #E65100; }
.urgency-critical { background: var(--red); color: #fff; }

/* ========================================
   LOADING & END
   ======================================== */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.end-message {
    text-align: center;
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* ========================================
   MODAL
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(3px);
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: var(--surface);
    border-radius: 14px;
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
    box-shadow: var(--shadow-modal);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.modal-close:hover {
    background: var(--gray-light);
    color: var(--text);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.modal-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.modal-urgency {
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--text);
    margin-bottom: 6px;
}

.modal-time {
    display: block;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 18px;
}

.modal-details {
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text);
    margin-bottom: 20px;
    white-space: pre-wrap;
}

.modal-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.modal-meta .tag {
    font-size: 0.78rem;
}

.meta-impact {
    padding: 3px 12px;
    border-radius: var(--radius-tag);
    font-size: 0.78rem;
    font-weight: 600;
}

.impact-negatywny { background: var(--red-light); color: #C62828; }
.impact-pozytywny { background: var(--green-light); color: #2E7D32; }
.impact-neutralny { background: var(--gray-light); color: var(--gray); }

.meta-date {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
}

.modal-link {
    display: inline-block;
    padding: 10px 24px;
    background: var(--blue);
    color: #fff;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background var(--transition);
}

.modal-link:hover {
    background: var(--blue-dark);
    text-decoration: none;
}

.modal-link.hidden {
    display: none;
}

/* ========================================
   FOOTER
   ======================================== */
.bottom-bar {
    text-align: center;
    padding: 20px var(--content-pad);
    font-size: 0.82rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--surface);
    margin-top: auto;
}

/* ========================================
   UTILITY
   ======================================== */
.hidden {
    display: none !important;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1024px) {
    .top-bar-inner {
        gap: 12px;
    }

    .search-wrapper {
        max-width: 320px;
    }
}

/* Mobile */
@media (max-width: 640px) {
    :root {
        --content-pad: 14px;
    }

    .top-bar-inner {
        height: auto;
        padding: 12px var(--content-pad);
        flex-wrap: wrap;
    }

    .search-wrapper {
        order: 3;
        max-width: 100%;
        flex-basis: 100%;
    }

    .nav-links {
        margin-left: auto;
    }

    .filters-row {
        flex-direction: column;
        gap: 14px;
    }

    .filter-group {
        gap: 6px;
    }

    .filter-tag {
        padding: 4px 10px;
        font-size: 0.78rem;
    }

    .modal-card {
        padding: 22px 18px;
        max-height: 90vh;
    }

    .modal-title {
        font-size: 1.1rem;
    }

    .card-right {
        min-width: 64px;
        padding: 10px 10px;
    }

    .news-grid {
        gap: 8px;
    }
}

/* ========================================
   URGENT BAR — Flip Clock Cards
   ======================================== */
.urgent-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #1a1a2e;
    color: #fff;
    z-index: 3000;
    display: flex;
    align-items: center;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.4);
}

.urgent-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    flex-shrink: 0;
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    height: 100%;
    border-right: 1px solid rgba(255,255,255,0.1);
}

.urgent-pulse {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--red);
    border-radius: 50%;
    animation: urgentPulse 1.2s ease-in-out infinite;
}

.urgent-text {
    color: var(--red);
}

@keyframes urgentPulse {
    0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(244,67,54,0.6); }
    50% { opacity: 0.8; transform: scale(1.3); box-shadow: 0 0 8px 4px rgba(244,67,54,0.2); }
}

/* Flip container */
.urgent-flip-wrap {
    flex: 1;
    overflow: hidden;
    height: 100%;
    perspective: 600px;
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.urgent-flip-card {
    width: 100%;
    height: 40px;
    position: relative;
    transform-style: preserve-3d;
}

.urgent-flip-face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    backface-visibility: hidden;
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    transition: background 0.15s;
}

.urgent-flip-face:hover {
    background: rgba(255,255,255,0.08);
}

.urgent-flip-front {
    transform: rotateX(0deg);
}

.urgent-flip-back {
    transform: rotateX(-90deg);
    transform-origin: bottom center;
}

/* Flip animation */
.urgent-flip-card.flipping .urgent-flip-front {
    animation: flipOut 0.6s ease-in-out forwards;
}

.urgent-flip-card.flipping .urgent-flip-back {
    animation: flipIn 0.6s ease-in-out forwards;
}

@keyframes flipOut {
    0% { transform: rotateX(0deg); }
    100% { transform: rotateX(90deg); }
}

@keyframes flipIn {
    0% { transform: rotateX(-90deg); }
    100% { transform: rotateX(0deg); }
}

.urgent-flip-date {
    color: rgba(255,255,255,0.5);
    margin-right: 8px;
    font-size: 0.82rem;
    font-family: monospace;
}

/* Add bottom padding to body when urgent bar is visible */
body.has-urgent-bar {
    padding-bottom: 60px;
}

body.has-urgent-bar .bottom-bar {
    margin-bottom: 60px;
}
