/* Custom CSS overrides for MiPorog */

/* Adjust search and palette toggle position on desktop - push to the right */
@media screen and (min-width: 60em) {
    /* Force the header inner to use flexbox and align items to the right */
    .md-header__inner {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    /* Ensure title stays on the left */
    .md-header__title {
        flex: 0 0 auto !important;
        margin-right: auto !important;
    }

    /* Position palette toggle to the right, before search */
    .md-header__option[data-md-component="palette"] {
        order: 98 !important;
        margin-left: auto !important;
        margin-right: 1rem !important;
    }

    /* Position search all the way to the right */
    .md-search {
        order: 99 !important;
        margin-left: 0 !important;
        margin-right: 0.5rem !important;
    }
}

/* On mobile, reset to default */
@media screen and (max-width: 59.984375em) {
    .md-header__inner {
        display: flex !important;
    }

    .md-header__option[data-md-component="palette"],
    .md-search {
        order: unset !important;
        margin-left: unset !important;
        margin-right: unset !important;
    }
}

/* ============================================
   AI Chat Button Styles
   ============================================ */

/* Container for the AI chat button */
.ai-chat-container {
    position: relative;
    display: inline-block;
    margin: 1.5rem 0;
}

/* Main button */
.ai-chat-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.ai-chat-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-chat-button:active {
    transform: translateY(0);
}

/* Dropdown menu */
.ai-chat-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.5rem;
    min-width: 160px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    overflow: hidden;
}

.ai-chat-dropdown--visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown items */
.ai-chat-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: #333;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
    text-align: left;
}

.ai-chat-dropdown-item:hover {
    background-color: #f5f5f5;
}

.ai-chat-dropdown-item:not(:last-child) {
    border-bottom: 1px solid #eee;
}

/* Toast notifications */
.ai-chat-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 0.75rem 1.5rem;
    background: #333;
    color: #fff;
    border-radius: 8px;
    font-size: 0.85rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10000;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ai-chat-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.ai-chat-toast--success {
    background: linear-gradient(135deg, #34a853 0%, #2e7d32 100%);
}

.ai-chat-toast--error {
    background: linear-gradient(135deg, #ea4335 0%, #c62828 100%);
}

/* Dark mode support */
[data-md-color-scheme="slate"] .ai-chat-dropdown {
    background: #2d2d2d;
}

[data-md-color-scheme="slate"] .ai-chat-dropdown-item {
    color: #e0e0e0;
}

[data-md-color-scheme="slate"] .ai-chat-dropdown-item:hover {
    background-color: #3d3d3d;
}

[data-md-color-scheme="slate"] .ai-chat-dropdown-item:not(:last-child) {
    border-bottom-color: #444;
}

/* Mobile responsiveness */
@media screen and (max-width: 59.984375em) {
    .ai-chat-container {
        display: block;
        margin: 1rem 0;
    }

    .ai-chat-button {
        width: 100%;
        justify-content: center;
    }

    .ai-chat-dropdown {
        width: 100%;
    }

    .ai-chat-toast {
        left: 1rem;
        right: 1rem;
        transform: translateY(20px);
        max-width: none;
    }

    .ai-chat-toast--visible {
        transform: translateY(0);
    }
}

/* ============================================
   Hero Image for Article Pages
   ============================================ */

.hero-image {
    margin: 0 0 1.5rem 0;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.hero-image img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: block;
}

/* Bottom gradient for readability */
.hero-image::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
    pointer-events: none;
}

/* Mobile */
@media screen and (max-width: 59.984375em) {
    .hero-image img {
        height: 200px;
    }
}

/* ============================================
   Tag Filter Bar & Card Grid (Landing Page Feed)
   ============================================ */

/* Tag filter container */
#tag-filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0 1.5rem 0;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
}

[data-md-color-scheme="slate"] #tag-filter-container {
    background: rgba(255, 255, 255, 0.05);
}

/* Tag buttons */
.tag-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: #666;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0.6;
}

.tag-btn:hover {
    opacity: 1;
    border-color: var(--tag-color, #5c9fd4);
}

.tag-btn.active {
    opacity: 1;
    color: #fff;
    background: var(--tag-color, #5c9fd4);
    border-color: var(--tag-color, #5c9fd4);
}

.tag-btn-none,
.tag-btn-reset {
    background: transparent;
    border-style: dashed;
    color: #888;
}

.tag-btn-none:hover,
.tag-btn-reset:hover {
    background: #f5f5f5;
}

[data-md-color-scheme="slate"] .tag-btn {
    background: #2d2d2d;
    border-color: #444;
    color: #aaa;
}

[data-md-color-scheme="slate"] .tag-btn.active {
    color: #fff;
}

[data-md-color-scheme="slate"] .tag-btn-none:hover,
[data-md-color-scheme="slate"] .tag-btn-reset:hover {
    background: #3d3d3d;
}

/* Card grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

/* Individual card */
.feed-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    padding: 1rem;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.feed-card:hover {
    border-color: rgba(92, 159, 212, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

[data-md-color-scheme="slate"] .feed-card {
    background: #2d2d2d;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-md-color-scheme="slate"] .feed-card:hover {
    border-color: rgba(92, 159, 212, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Card header with tag and time */
.feed-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

/* Category tag pill */
.feed-card-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    background: var(--tag-color, #5c9fd4);
    border-radius: 12px;
}

/* Timestamp */
.feed-card-time {
    font-size: 0.7rem;
    color: #999;
}

[data-md-color-scheme="slate"] .feed-card-time {
    color: #666;
}

/* Card title */
.feed-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0.25rem 0 0.5rem 0;
}

.feed-card-title a {
    color: #333 !important;
    text-decoration: none;
    transition: color 0.15s ease;
}

.feed-card-title a:hover {
    color: #5c9fd4 !important;
}

[data-md-color-scheme="slate"] .feed-card-title a {
    color: #e0e0e0 !important;
}

[data-md-color-scheme="slate"] .feed-card-title a:hover {
    color: #5c9fd4 !important;
}

/* Card summary */
.feed-card-summary {
    font-size: 0.8rem;
    color: #666;
    line-height: 1.5;
    margin: 0;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

[data-md-color-scheme="slate"] .feed-card-summary {
    color: #999;
}

/* No results message */
#no-results-message {
    display: none;
    text-align: center;
    padding: 2rem;
    color: #888;
    font-style: italic;
}

/* Hero card (featured story) - subtle design */
.hero-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-left: 4px solid #5c9fd4;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

[data-md-color-scheme="slate"] .hero-card {
    background: #2d2d2d;
    border-color: rgba(255, 255, 255, 0.1);
    border-left-color: #5c9fd4;
}

.hero-card h3,
.hero-card strong {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    color: #333 !important;
    display: block;
}

[data-md-color-scheme="slate"] .hero-card h3,
[data-md-color-scheme="slate"] .hero-card strong {
    color: #e0e0e0 !important;
}

.hero-card p {
    margin: 0 0 0.75rem 0;
    font-size: 0.85rem;
    color: #555;
    line-height: 1.5;
}

[data-md-color-scheme="slate"] .hero-card p {
    color: #aaa;
}

.hero-card .md-button {
    font-size: 0.75rem !important;
    padding: 0.3rem 0.6rem !important;
}

/* Mobile adjustments */
@media screen and (max-width: 59.984375em) {
    .card-grid {
        grid-template-columns: 1fr;
    }

    #tag-filter-container {
        gap: 0.4rem;
    }

    .tag-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }
}
