@php
    $topheader = App\Models\TopHeader::first();
    $headerLogo = App\Models\HeaderLogo::first();
@endphp

<div class="top-header-bar">
    <div class="top-header-container">
        <div class="top-header-logo">
            @if ($headerLogo)
                <div>
                    <a href="{{ $headerLogo->url }}">
                        <img src="{{ asset('storage/' . $headerLogo->logo) }}" alt="Logo" />
                    </a>
                </div>
                <div class="top-header-text">
                    <span class="top-header-slogan">
                        {{ $headerLogo->slogan }}
                    </span>
                    <h1 class="top-header-title">
                        {{ $headerLogo->title }}
                    </h1>
                </div>

            @endif
        </div>
        <div class="top-header-links">
            @if ($topheader)
                <div class="top-header-link" onclick="window.location.href='{{ route('facility') }}'">
                    @if ($topheader->icon_facility)
                        <img src="{{ asset('storage/' . $topheader->icon_facility) }}" alt="Facility Icon" class="icon-img" />
                    @endif
                    <span>{{ strtoupper($topheader->facilities_tittle) }}</span>
                </div>
                <div class="top-header-link" onclick="window.location.href='{{ route('studentLife') }}'">
                    @if ($topheader->icon_studentlife)
                        <img src="{{ asset('storage/' . $topheader->icon_studentlife) }}" alt="Student Life Icon" class="icon-img" />
                    @endif
                    <span>{{ strtoupper($topheader->studentlife_tittle) }}</span>
                </div>
                @if ($topheader->search_status)
                    <div class="input-wrapper">
                        <form action="{{ route('search') }}" method="GET" class="search-form">
                            <button type="button" class="icon" tabindex="-1">
                                <svg
                                    width="25px"
                                    height="25px"
                                    viewBox="0 0 24 24"
                                    fill="none"
                                    xmlns="http://www.w3.org/2000/svg"
                                >
                                    <path
                                        d="M11.5 21C16.7467 21 21 16.7467 21 11.5C21 6.25329 16.7467 2 11.5 2C6.25329 2 2 6.25329 2 11.5C2 16.7467 6.25329 21 11.5 21Z"
                                        stroke="#979797 "
                                        stroke-width="1.5"
                                        stroke-linecap="round"
                                        stroke-linejoin="round"
                                    ></path>
                                    <path
                                        d="M22 22L20 20"
                                        stroke="#979797 "
                                        stroke-width="1.5"
                                        stroke-linecap="round"
                                        stroke-linejoin="round"
                                    ></path>
                                </svg>
                            </button>
                            <input type="text" name="text" class="input" placeholder="search.." />
                        </form>
                    </div>
                @endif
            @endif
        </div>
    </div>
</div>

<style>
.top-header-bar {
    width: 100%;
    padding: 0;
}
.top-header-container {
    background: #fff;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 32px 8px 16px;

}
.top-header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.top-header-logo img {
    height: 65px;
    width: auto;
}
.top-header-text {
    display: flex;
    flex-direction: column;
}
.top-header-slogan {
    font-weight: 400;
    font-size: 8px;
    line-height: 20px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #525558;
}
.top-header-title {
    max-width: 250px;
    font-family: Poppins;
    font-weight: 600;
    font-size: 12px;
    line-height: 20px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #004675;
}
.top-header-links {
    display: flex;
    align-items: center;
    gap: 20px;
}
.top-header-link {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: Poppins;
    font-weight: 500;
    font-size: 14px;
    line-height: 20px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #004675;
    padding: 6px 18px;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    cursor: pointer;
}
.top-header-link .icon-img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    display: block;
    transition: filter 0.2s;
}
.top-header-search {
    margin-left: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.top-header-search:hover {
    opacity: 1;
}
@media (max-width: 900px) {
    .top-header-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 8px 10px;
    }
    .top-header-links {
        gap: 18px;
    }
}

/* Hover and active styles */
.top-header-link:hover,
.top-header-link:active {
    background: #f7931e;
    color: #fff;
}

.top-header-link:hover .icon-img,
.top-header-link:active .icon-img {
    filter: brightness(0) invert(1);
}

.input-wrapper {
  display: flex;
  align-items: center;
  position: relative;
  margin-left: 18px;
}

.search-form {
  display: flex;
  align-items: center;
  position: relative;
}

.input {
  border: none;
  border-bottom: 2.5px solid #004675;
  background: transparent;
  color: #004675;
  height: 38px;
  width: 0;
  min-width: 0;
  padding: 0;
  margin-left: 0;
  outline: none;
  font-size: 17px;
  font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande",
    "Lucida Sans", Arial, sans-serif;
  opacity: 0;
  transition: width 0.4s cubic-bezier(0, 0.11, 0.35, 2), opacity 0.3s;
}

.icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 0;
  margin-right: 0;
  width: 38px;
  height: 38px;
  transition: background 0.2s;
  border-radius: 50%;
}

/* Show input on icon hover */
.input-wrapper:hover .input,
.input-wrapper:focus-within .input {
  width: 180px;
  opacity: 1;
  padding-left: 12px;
  margin-left: 8px;
}

.input::placeholder {
  color: #8f8f8f;
  font-size: 17px;
}

/* Optional: icon hover effect */
.icon:hover {
  background: #e6f0ff;
}
</style>
