/**
 * YouHomepage - Custom Styles
 *
 * Custom theme built on Bootstrap Italia
 * Modern, clean and pleasant design
 *
 * @package YouHomepage
 * @author  YouHomepage Team
 * @license MIT
 */

/* ============================================================================
   Variables and Theme
   ========================================================================= */

:root
{
    --yh-primary: #0066CC;
    --yh-secondary: #5C6F82;
    --yh-success: #008758;
    --yh-warning: #A66300;
    --yh-danger: #D9364F;
    --yh-info: #0073E6;
    --yh-light: #F5F6F7;
    --yh-dark: #17324D;

    --yh-card-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --yh-card-hover-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    --yh-border-radius: 8px;
    --yh-transition: all 0.3s ease;
}

/* ============================================================================
   Global Styles
   ========================================================================= */

body
{
    font-family: 'Titillium Web', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

/* ============================================================================
   Navbar
   ========================================================================= */

.navbar
{
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, var(--yh-primary) 0%, #0052a3 100%) !important;
}

.navbar-brand
{
    font-weight: 700;
    font-size: 1.5rem;
    transition: var(--yh-transition);
}

.navbar-brand:hover
{
    transform: scale(1.05);
}

/* ============================================================================
   Cards
   ========================================================================= */

.card
{
    border: none;
    border-radius: var(--yh-border-radius);
    box-shadow: var(--yh-card-shadow);
    transition: var(--yh-transition);
}

.card:hover
{
    box-shadow: var(--yh-card-hover-shadow);
    transform: translateY(-2px);
}

/* Disable lift effect for cards with dropdowns */
.card-no-lift:hover
{
    transform: none;
}

.card-header
{
    border-bottom: none;
    font-weight: 600;
    padding: 1rem 1.5rem;
}

.card-header h5
{
    font-size: 1.1rem;
}

/* Improve contrast for warning backgrounds */
.card-header.bg-warning
{
    background-color: #ffc107 !important;
    color: #000 !important;
}

.card-header.bg-warning .badge.bg-dark
{
    background-color: #212529 !important;
    color: #fff !important;
}

/* Ensure card headers have good contrast by default */
.card-header
{
    background-color: #f8f9fa;
    color: #212529;
}

.bookmark-card
{
    transition: var(--yh-transition);
    position: relative;
}

.bookmark-card .card-body
{
    display: flex;
    flex-direction: column;
    padding-bottom: 4rem;
    min-height: 180px;
}

.bookmark-card .bookmark-tags-display
{
    position: absolute;
    bottom: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
    margin-top: 0 !important;
    max-height: 3rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.card-body .h-80
{
    height: 80% !important;
}

.bookmark-card:hover
{
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* Hide bookmark action buttons by default on desktop */
@media (min-width: 769px)
{
    .bookmark-card .bookmark-actions
    {
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    /* Show buttons on card hover on desktop */
    .bookmark-card:hover .bookmark-actions
    {
        opacity: 1;
    }
}

/* Always show buttons on mobile/tablet */
@media (max-width: 768px)
{
    .bookmark-card .bookmark-actions
    {
        opacity: 1;
    }
}

/* ============================================================================
   Favicon
   ========================================================================= */

.favicon
{
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
}

/* ============================================================================
   Buttons
   ========================================================================= */

.btn
{
    border-radius: var(--yh-border-radius);
    font-weight: 500;
    transition: var(--yh-transition);
    border: none;
    padding: 0.5rem 1.25rem;
}

.btn-primary
{
    background: linear-gradient(135deg, var(--yh-primary) 0%, #0052a3 100%);
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.3);
}

.btn-primary:hover
{
    background: linear-gradient(135deg, #0052a3 0%, #003d7a 100%);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.4);
    transform: translateY(-1px);
}

.btn-outline-primary
{
    border: 2px solid var(--yh-primary);
    color: var(--yh-primary);
}

.btn-outline-primary:hover
{
    background: var(--yh-primary);
    color: white;
}

.btn-sm
{
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

/* ============================================================================
   Forms
   ========================================================================= */

.form-control,
.form-select
{
    border-radius: var(--yh-border-radius);
    border: 2px solid #e3e8ef;
    transition: var(--yh-transition);
    padding: 0.75rem 1rem;
}

.form-control:focus,
.form-select:focus
{
    border-color: var(--yh-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.15);
}

.form-control-lg
{
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
}

/* ============================================================================
   Search Bar
   ========================================================================= */

#searchForm
{
    position: relative;
}

#searchInput
{
    border-radius: 50px;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 2px solid transparent;
}

#searchInput:focus
{
    box-shadow: 0 4px 16px rgba(0, 102, 204, 0.2);
    border-color: var(--yh-primary);
}

/* ============================================================================
   Badges
   ========================================================================= */

.badge
{
    border-radius: 20px;
    padding: 0.4em 0.8em;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Ensure badges have proper contrast */
.badge.bg-light
{
    background-color: #f8f9fa !important;
    color: #212529 !important;
}

.badge.bg-secondary
{
    background-color: #6c757d !important;
    color: #fff !important;
}

/* Dark text for badges with light backgrounds */
.badge.text-dark
{
    color: #000 !important;
}

/* ============================================================================
   Alerts
   ========================================================================= */

.alert
{
    border-radius: var(--yh-border-radius);
    border: none;
    box-shadow: var(--yh-card-shadow);
}

.alert-success
{
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.alert-danger
{
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
}

.alert-warning
{
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
}

.alert-info
{
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
}

/* ============================================================================
   Modal
   ========================================================================= */

.modal-content
{
    border-radius: var(--yh-border-radius);
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header
{
    border-bottom: 2px solid #e3e8ef;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.modal-footer
{
    border-top: 2px solid #e3e8ef;
}

/* ============================================================================
   Tabs
   ========================================================================= */

.nav-tabs
{
    border-bottom: 2px solid #e3e8ef;
}

.nav-tabs .nav-link
{
    border: none;
    color: #6c757d;
    font-weight: 500;
    padding: 0.75rem 1.25rem;
    transition: var(--yh-transition);
}

.nav-tabs .nav-link:hover
{
    color: var(--yh-primary);
    border-color: transparent;
}

.nav-tabs .nav-link.active
{
    color: var(--yh-primary);
    background-color: transparent;
    border-bottom: 3px solid var(--yh-primary);
    font-weight: 600;
}

.nav-tabs .nav-link .badge
{
    font-size: 0.7em;
    vertical-align: middle;
    margin-left: 0.5rem;
}

.tab-content
{
    padding-top: 1rem;
}

/* ============================================================================
   Form Checks (Checkboxes & Radios)
   ========================================================================= */

.form-check-input:checked
{
    background-color: var(--yh-primary);
    border-color: var(--yh-primary);
}

.form-check-label
{
    cursor: pointer;
    user-select: none;
}

/* ============================================================================
   Dropdown
   ========================================================================= */

.dropdown-menu
{
    border-radius: var(--yh-border-radius);
    border: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 0.5rem;
    min-width: 280px !important;
    max-width: 95vw !important;
    z-index: 9999;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    position: absolute;
    right: 0 !important;
    left: auto !important;
}

.dropdown-item
{
    border-radius: 6px;
    margin-bottom: 0.25rem;
    padding: 0.35rem 0.75rem;
    transition: var(--yh-transition);
}

.dropdown-item:hover
{
    background: var(--yh-primary);
    color: white;
}

.dropdown-divider
{
    margin: 0.5rem 0;
}

/* Language selector - fix active item visibility */
.language-selector .dropdown-item.active
{
    background-color: var(--yh-primary);
    color: white !important;
}

.language-selector .dropdown-item.active:hover
{
    background-color: #0052a3;
    color: white !important;
}

/* Search engine dropdown - fix positioning */
#searchEngineDropdown + .dropdown-menu
{
    right: auto !important;
    left: 0 !important;
}

/* Search engine selector - highlight active item */
.search-engine-option.active
{
    background-color: var(--yh-primary) !important;
    color: white !important;
    font-weight: 600;
}

.search-engine-option.active:hover
{
    background-color: #0052a3 !important;
    color: white !important;
}

/* ============================================================================
   Welcome Screen
   ========================================================================= */

.display-4
{
    font-weight: 700;
    background: linear-gradient(135deg, var(--yh-primary) 0%, #0052a3 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================================================
   Links
   ========================================================================= */

a
{
    color: var(--yh-primary);
    transition: var(--yh-transition);
}

a:hover
{
    color: #0052a3;
    text-decoration: none;
}

.card-title a
{
    color: var(--yh-dark);
    font-weight: 600;
}

.card-title a:hover
{
    color: var(--yh-primary);
}

/* ============================================================================
   Responsive Design
   ========================================================================= */

@media (max-width: 768px)
{
    .navbar-brand
    {
        font-size: 1.25rem;
    }

    .card-body
    {
        padding: 1rem;
    }

    .btn-sm
    {
        padding: 0.2rem 0.5rem;
        font-size: 0.8rem;
    }

    .favicon
    {
        width: 20px;
        height: 20px;
    }

    h1.display-4
    {
        font-size: 2rem;
    }
}

/* ============================================================================
   Animations
   ========================================================================= */

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

.card
{
    animation: fadeIn 0.5s ease-out;
}

/* ============================================================================
   Utilities
   ========================================================================= */

.text-muted
{
    color: #6c757d !important;
}

.shadow
{
    box-shadow: var(--yh-card-shadow) !important;
}

.shadow-sm
{
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06) !important;
}

.shadow-lg
{
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
}

/* ============================================================================
   Loading State
   ========================================================================= */

.loading
{
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after
{
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--yh-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ============================================================================
   Color Palette for Tag Selection
   ========================================================================= */

.color-palette
{
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.5rem;
    max-width: 400px;
}

.color-btn
{
    width: 48px;
    height: 48px;
    border: 3px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--yh-transition);
    position: relative;
    padding: 0;
}

.color-btn:hover
{
    transform: scale(1.1);
    border-color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.color-btn.active
{
    border-color: #000;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #000;
    transform: scale(1.05);
}

.color-btn.active::after
{
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

/* ============================================================================
   View Modes - Grid and List
   ========================================================================= */

/* List view - compact layout */
.view-mode-list .bookmark-card
{
    margin-bottom: 0.25rem;
}

.view-mode-list .col-12.col-md-6.col-lg-4.col-xl-3
{
    flex: 0 0 100%;
    max-width: 100%;
}

.view-mode-list .bookmark-card .card-body
{
    padding: 0.3rem 0.6rem;
}

.view-mode-list .bookmark-card
{
    border-radius: 4px;
}

.view-mode-list .bookmark-card .card-body > *
{
    margin-bottom: 0 !important;
}

.view-mode-list .bookmark-card .d-flex.align-items-start
{
    margin-bottom: 0 !important;
}

.view-mode-list .bookmark-card .d-flex.justify-content-between
{
    margin-bottom: 0.15rem !important;
}

.view-mode-list .bookmark-card .card-text
{
    display: none !important;
}

/* No tooltip - keep it clean */

.view-mode-list .bookmark-card .small.text-muted
{
    display: inline-block;
    margin-right: 0.5rem;
    margin-bottom: 0;
    font-size: 0.75rem;
}

.view-mode-list .favicon
{
    width: 18px;
    height: 18px;
}

.view-mode-list .bookmark-card .d-flex.justify-content-between
{
    align-items: center;
    margin-bottom: 0 !important;
}

.view-mode-list .bookmark-card .card-title
{
    font-size: 0.85rem;
    display: inline;
    line-height: 1.3;
}

.view-mode-list .bookmark-card:hover
{
    transform: none;
}

.view-toggle.active
{
    background-color: var(--yh-primary);
    color: white;
    border-color: var(--yh-primary);
}

/* Multi-column layout for organized sections in list view */
.view-mode-list-columns
{
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.view-mode-list-columns > .card
{
    margin-bottom: 0;
}

@media (min-width: 768px)
{
    .view-mode-list-columns > .card
    {
        flex: 0 0 calc(50% - 0.5rem);
    }
}

@media (min-width: 992px)
{
    .view-mode-list-columns > .card
    {
        flex: 0 0 calc(33.333% - 0.67rem);
    }
}

@media (min-width: 1200px)
{
    .view-mode-list-columns > .card
    {
        flex: 0 0 calc(25% - 0.75rem);
    }
}

@media (min-width: 1400px)
{
    .view-mode-list-columns > .card
    {
        flex: 0 0 calc(20% - 0.8rem);
    }
}

/* ============================================================================
   Tag Filter Styles
   ========================================================================= */

#tagFilterContainer .form-check-inline
{
    margin: 0;
}

#tagFilterContainer .form-check-input
{
    display: none;
}

#tagFilterContainer .form-check [type=checkbox]:not(:checked) + label::before,
#tagFilterContainer .form-check [type=checkbox]:checked + label::before,
#tagFilterContainer .form-check [type=checkbox]:not(:checked) + label::after,
#tagFilterContainer .form-check [type=checkbox]:checked + label::after
{
    display: none !important;
    content: none !important;
}

#tagFilterContainer .badge
{
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

#tagFilterContainer .form-check-input:checked + .badge
{
    border-color: #000;
    box-shadow: 0 0 0 1px #000;
}

.filter-mode-toggle
{
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 2px;
    background-color: #f8f9fa;
}

.filter-mode-toggle .btn
{
    font-weight: 500;
    min-width: 45px;
    padding: 0.25rem 0.75rem;
    border: none;
    background: transparent;
    color: #6c757d;
    border-radius: 18px;
    transition: all 0.2s ease;
}

.filter-mode-toggle .btn:hover
{
    color: var(--yh-primary);
}

.filter-mode-toggle .btn.active
{
    background-color: #2c3e50 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 4px rgba(44, 62, 80, 0.3) !important;
    font-weight: bold !important;
}

.bookmark-tags-display
{
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.bookmark-tag-badge
{
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.bookmark-tag-badge:hover
{
    transform: scale(1.05);
    opacity: 0.9;
}

/* ============================================================================
   PWA Info Bar (Discrete Install Prompt)
   ========================================================================= */

.pwa-info-bar
{
    background: linear-gradient(135deg, var(--yh-info) 0%, #0052a3 100%);
    color: white;
    position: sticky;
    top: 56px; /* Below navbar */
    z-index: 1020;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.4s ease-out;
}

.pwa-info-bar .pwa-info-text
{
    font-size: 0.95rem;
    font-weight: 500;
}

.pwa-info-bar .bi-lightbulb
{
    font-size: 1.2rem;
    color: #ffeb3b;
}

.pwa-info-bar .btn-primary
{
    background: white;
    color: var(--yh-primary);
    border: none;
    font-weight: 600;
    transition: var(--yh-transition);
}

.pwa-info-bar .btn-primary:hover
{
    background: #f0f0f0;
    transform: translateY(-1px);
}

.pwa-info-bar .btn-close-white
{
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.pwa-info-bar .btn-close-white:hover
{
    opacity: 1;
}

@keyframes slideDown
{
    from
    {
        transform: translateY(-100%);
        opacity: 0;
    }
    to
    {
        transform: translateY(0);
        opacity: 1;
    }
}

.pwa-info-bar.hiding
{
    animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp
{
    from
    {
        transform: translateY(0);
        opacity: 1;
    }
    to
    {
        transform: translateY(-100%);
        opacity: 0;
    }
}

/* Responsive PWA Info Bar */
@media (max-width: 768px)
{
    .pwa-info-bar .pwa-info-text
    {
        font-size: 0.85rem;
    }

    .pwa-info-bar .btn-sm
    {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

/* ============================================================================
   Dark Mode Support (Future Enhancement)
   ========================================================================= */

@media (prefers-color-scheme: dark)
{
    /* Dark mode styles can be added here in the future */
}
