/* HandyUtils - Custom Styles */
/* Brand Colors from PRD */
:root {
    --hu-blue: #3B82F6;
    --hu-green: #22C55E;
    --hu-amber: #F59E0B;
    --hu-purple: #A855F7;
}

/* Override Bootstrap primary color */
[data-bs-theme="light"] {
    --bs-primary: var(--hu-blue);
    --bs-primary-rgb: 59, 130, 246;
}

[data-bs-theme="dark"] {
    --bs-primary: var(--hu-blue);
    --bs-primary-rgb: 59, 130, 246;
}

/* Body and layout */
html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Navbar */
.navbar-brand {
    font-weight: 700;
}

.navbar .dropdown-menu {
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(168, 85, 247, 0.05) 100%);
}

[data-bs-theme="dark"] .hero-section {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
}

/* Cards */
.utility-card,
.category-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 1rem;
}

.utility-card:hover,
.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12) !important;
}

.category-card {
    color: inherit;
}

/* Utility icons */
.utility-icon,
.category-icon,
.feature-icon {
    transition: transform 0.2s ease;
}

.utility-card:hover .utility-icon,
.category-card:hover .category-icon {
    transform: scale(1.1);
}

/* Favorite button */
.favorite-btn {
    color: var(--bs-danger) !important;
    border: none !important;
    background: transparent !important;
    transition: transform 0.2s ease;
}

.favorite-btn:hover {
    color: var(--bs-danger) !important;
    transform: scale(1.1);
    background: transparent !important;
}

.favorite-btn:focus {
    color: var(--bs-danger) !important;
    box-shadow: none !important;
}

.favorite-btn.active {
    transform: scale(1.1);
}

.favorite-btn.active i {
    animation: heartbeat 0.3s ease;
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Swap button */
.swap-btn {
    width: 48px;
    height: 48px;
    transition: transform 0.3s ease;
}

.swap-btn:active {
    transform: rotate(180deg);
}

/* Copy button feedback */
.copy-btn.btn-success {
    transition: all 0.2s ease;
}

/* Search dropdown */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1050;
    display: none;
}

.search-dropdown.show {
    display: block;
}

.search-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--bs-body-color);
    border-bottom: 1px solid var(--bs-border-color);
    transition: background-color 0.15s ease;
}

.search-dropdown-item:last-child {
    border-bottom: none;
}

.search-dropdown-item:hover,
.search-dropdown-item.active {
    background-color: var(--bs-tertiary-bg);
}

.search-dropdown-item .icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.1);
    color: var(--hu-blue);
}

.search-section-header {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color);
    background: var(--bs-tertiary-bg);
    border-bottom: 1px solid var(--bs-border-color);
}

.search-section-header:not(:first-child) {
    border-top: 1px solid var(--bs-border-color);
}

/* Ad containers */
.ad-container {
    background: var(--bs-tertiary-bg);
    border-radius: 0.5rem;
    padding: 0.5rem;
}

.ad-leaderboard {
    max-width: 728px;
    margin-left: auto;
    margin-right: auto;
}

.ad-skyscraper {
    position: sticky;
    top: 80px;
    width: 176px; /* 160px image + 16px padding */
}

.ad-link img {
    border-radius: 0.25rem;
}

/* Form controls */
.form-control:focus,
.form-select:focus {
    border-color: var(--hu-blue);
    box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25);
}

/* Tables */
.table thead {
    position: sticky;
    top: 0;
}

/* Quick reference table */
.table-hover tbody tr {
    cursor: default;
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
    .ad-skyscraper {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .hero-section h1 {
        font-size: 1.75rem;
    }

    .dropdown-mega .row {
        min-width: auto !important;
    }

    .dropdown-mega .col-6 {
        width: 100%;
    }
}

/* Dark mode specific */
[data-bs-theme="dark"] {
    --bs-body-bg: #0f172a;
    --bs-body-color: #e2e8f0;
    --bs-tertiary-bg: #1e293b;
    --bs-border-color: #334155;
}

[data-bs-theme="dark"] .card {
    background-color: var(--bs-tertiary-bg);
}

[data-bs-theme="dark"] .bg-body-tertiary {
    background-color: #1e293b !important;
}

[data-bs-theme="dark"] .text-body-secondary {
    color: #94a3b8 !important;
}

/* Smooth theme transition - only activates after user interaction to avoid CLS.
   The .theme-ready class is added by JS after first theme toggle. */
.theme-ready body,
.theme-ready .card,
.theme-ready .navbar,
.theme-ready footer,
.theme-ready .bg-body-tertiary,
.theme-ready .form-control,
.theme-ready .btn {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Loading states */
.loading-shimmer {
    background: linear-gradient(90deg, var(--bs-tertiary-bg) 25%, var(--bs-body-bg) 50%, var(--bs-tertiary-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--hu-blue);
    outline-offset: 2px;
}

/* Admin dashboard table styling for dark mode */
[data-bs-theme="dark"] .table thead.table-light,
[data-bs-theme="dark"] .table tfoot.table-light {
    --bs-table-bg: rgba(255, 255, 255, 0.05);
    --bs-table-color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .table thead.table-light th,
[data-bs-theme="dark"] .table tfoot.table-light td {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--bs-body-color);
}

/* Print styles */
@media print {
    .navbar,
    footer,
    .ad-container,
    .favorite-btn,
    .swap-btn {
        display: none !important;
    }
}
