@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;500;600&display=swap');

* {
    margin: 0;
    padding: 0;
    border: 0;
    box-sizing: border-box;
    font-family: 'Montserrat', sans-serif;
}

body {
    height: 100vh;
    background: rgb(39, 0, 59);
    background: linear-gradient(360deg, rgba(39, 0, 59, 1) 0%, rgba(82, 0, 194, 1) 100%);
}

.container {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    align-items: start;
    padding: 1.6rem;
}

.main-content {
    min-width: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.02) 100%);
    padding: 1.2rem;
    border-radius: 0.8em;
    box-shadow: 0 12px 40px rgba(10, 4, 18, 0.18);
    min-height: 320px;
    /* garante espaço inicial */
}

.sidebar {
    position: sticky;
    top: 1.6rem;
}

.panel {
    background: #fff;
    border-radius: 0.6em;
    padding: 0.9rem;
    margin-bottom: 1rem;
    box-shadow: 0 8px 24px rgba(39, 0, 59, 0.04);
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}

.panel-head h4 {
    font-size: 0.95rem;
    color: #2a0038;
}

.small-link {
    background: transparent;
    border: none;
    color: #5200c2;
    cursor: pointer;
    font-size: 0.85rem;
}

.list {
    list-style: none;
    display: grid;
    gap: 0.6rem;
    max-height: 220px;
    overflow-y: auto;
}

.list li {
    display: flex;
    justify-content: space-between;
    gap: 0.6rem;
    align-items: center;
    padding: 0.45rem 0.6rem;
    border-radius: 0.4em;
    transition: background 0.12s;
    cursor: default;
}

.list li:hover {
    background: rgba(82, 0, 194, 0.04);
}

.list .meta {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
    color: #27003b;
}

.list .actions {
    flex: 0 0 auto;
    display: flex;
    gap: 0.4rem;
}

.icon-btn {
    background: rgba(82, 0, 194, 0.06);
    border-radius: 0.4em;
    border: none;
    padding: 0.35rem;
    cursor: pointer;
}

.icon-btn i {
    color: #4200b0;
}

/* ===== Melhoria visual da barra de pesquisa =====
   - Input e botão alinhados com mesma altura
   - Bordas arredondadas e sombra sutil
   - Botão com gradiente, ícone e texto alinhados
   - Ajustes responsivos
*/
.search-container {
    display: flex;
    gap: 0.9em;
    /* espaçamento entre input e botão */
    align-items: center;
    /* alinha verticalmente */
}

.input-wrap {
    position: relative;
    flex: 1 1 auto;
    /* ocupa o máximo de largura possível */
}

/* Input principal */
#movie-name {
    width: 100%;
    padding: 0.9em 1em;
    height: 48px;
    font-size: 1rem;
    border-radius: 0.6em;
    border: 1px solid #e6e6e6;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 6px 18px rgba(39, 0, 59, 0.03);
    outline: none;
    transition: box-shadow 0.12s ease, transform 0.06s ease;
    background: #fff;
}

#movie-name:focus {
    box-shadow: 0 8px 28px rgba(82, 0, 194, 0.12);
    transform: translateY(-1px);
}

/* Botão de pesquisa */
#search-button {
    display: inline-flex;
    align-items: center;
    gap: 0.6em;
    justify-content: center;
    min-width: 118px;
    height: 48px;
    padding: 0 1rem;
    border-radius: 0.6em;
    background: linear-gradient(180deg, #5b00d1 0%, #30006a 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(82, 0, 194, 0.18);
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
    font-weight: 600;
}

#search-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(82, 0, 194, 0.22);
}

#search-button:active {
    transform: translateY(0);
}

#search-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* texto e ícone dentro do botão */
#btn-text {
    font-size: 0.95rem;
    line-height: 1;
}

#search-button i {
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.95rem;
}

/* Ajustes para o spinner dentro do botão (quando visível) */
#btn-spinner {
    width: 0.95em;
    height: 0.95em;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    animation: spin 0.9s linear infinite;
}

/* Sugestões: garantir largura igual ao input e separação do botão */
.suggestions {
    z-index: 60;
    box-shadow: 0 12px 30px rgba(39, 0, 59, 0.08);
}

/* mobile tweaks */
@media screen and (max-width: 600px) {

    #movie-name,
    #search-button {
        height: 44px;
    }

    #search-button {
        min-width: 90px;
        padding: 0 0.75rem;
    }
}

/* small accessibility: foco claro ao navegar por teclado */
#search-button:focus {
    outline: 3px solid rgba(82, 0, 194, 0.16);
    outline-offset: 3px;
}

#movie-name:focus {
    outline: 3px solid rgba(82, 0, 194, 0.10);
    outline-offset: 3px;
}

/* Suggestions dropdown */
.suggestions {
    position: absolute;
    top: calc(100% + 0.6em);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 0.4em;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 16em;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.suggestions.visible {
    display: block;
}

.suggestion-item {
    display: flex;
    gap: 0.8em;
    padding: 0.6em;
    align-items: center;
    cursor: pointer;
    transition: background 0.12s;
}

.suggestion-item:hover,
.suggestion-item.highlight {
    background: rgba(82, 0, 194, 0.06);
}

.suggestion-thumb {
    width: 40px;
    height: 56px;
    background-size: cover;
    background-position: center;
    border-radius: 0.3em;
    flex: 0 0 40px;
}

.suggestion-meta {
    font-size: 0.9em;
    color: #27003b;
}

.suggestion-title {
    font-weight: 600;
}

.suggestion-year {
    font-weight: 300;
    color: #5200c2;
    font-size: 0.85em;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    animation: spin 0.9s linear infinite;
}

#btn-spinner {
    margin-left: 0.6em;
    border-color: rgba(255, 255, 255, 0.25);
    border-top-color: #dfe0d3;
    width: 0.95em;
    height: 0.95em;
    display: inline-block;
    vertical-align: middle;
}

.hidden {
    display: none !important;
}

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

/* Skeleton card while loading details */
.skeleton {
    animation: pulse 1.2s infinite;
    background: linear-gradient(90deg, #f3f3f3 25%, #ececec 37%, #f3f3f3 63%);
    background-size: 400% 100%;
}

.skeleton-card {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 1em;
    align-items: start;
    margin-top: 1.2em;
}

.skeleton-thumb {
    width: 90px;
    height: 130px;
    border-radius: 0.4em;
}

.skeleton-lines {
    display: grid;
    gap: 0.6em;
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
    width: 100%;
}

@keyframes pulse {
    0% {
        background-position: 0% 0;
    }

    100% {
        background-position: 100% 0;
    }
}

#result {
    color: black;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.692) 0%, rgb(255, 255, 255) 100%);
    padding: 1.2rem;
    border-radius: 0.6em;
    margin-top: 1rem;
    box-shadow: inset 0 -6px 30px rgba(39, 0, 59, 0.02);
}

.info {
    position: relative;
    display: grid;
    grid-template-columns: 4fr 8fr;
    margin-top: 1.2em;
}

.poster {
    width: 90%;
    border-radius: 0.4em;
}

h2 {
    text-align: center;
    font-size: 1.5em;
    font-weight: 600;
    letter-spacing: 0.06em;
}

.rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6em;
    margin: 0.6em 0 0.9em 0;
}

.rating img {
    width: 1.2em;

}

.rating h4 {
    display: inline-block;
    font-size: 1.1em;
    font-weight: 500;
}

.details {
    display: flex;
    font-size: 0.95em;
    gap: 1em;
    justify-content: center;
    color: #5200c2;
    margin: 0.6em 0;
    font-weight: 300;
}

.genre {
    display: flex;
    justify-content: space-around;
}

.genre div {
    border: 1px solid #5200c2;
    padding: 0.4em 1.6em;
    border-radius: 0.4em;
    font-weight: 300;
}

h3 {
    font-weight: 500;
    margin-top: 1.2em;
}

p {
    font-size: 0.9em;
    font-weight: 300;
    line-height: 1.8em;
    text-align: justify;
    color: #5200c2;
}

.msg {
    text-align: center;
}

@media screen and (max-width: 600px) {
    .container {
        font-size: 14px;
    }

    .poster {
        margin: auto;
        width: auto;
        max-height: 10.8em;
    }

    .info {
        grid-template-columns: 1fr;
    }

    .suggestions {
        left: 0;
        right: 0;
    }
}

/* Responsividade: sidebar abaixo do conteúdo em telas menores */
@media screen and (max-width: 980px) {
    .container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        top: 0;
    }
}

/* ===== Resultado: poster, info e controles ===== */
.info {
    display: flex;
    gap: 1.2rem;
    align-items: flex-start;
}

.poster {
    width: 140px;
    height: 210px;
    object-fit: cover;
    border-radius: 0.5em;
    box-shadow: 0 10px 30px rgba(39, 0, 59, 0.06);
}

.info h2 {
    margin: 0 0 0.25rem 0;
    font-size: 1.25rem;
    color: #19002a;
}

.rating {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.rating img {
    width: 18px;
}

.details {
    color: #4b2e6f;
    font-size: 0.9rem;
    margin-top: 0.35rem;
}

.controls .icon-btn {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    padding: 0.5rem 0.65rem;
    border-radius: 0.45em;
    font-weight: 600;
}

.controls .icon-btn i {
    margin-right: 0.45rem;
}

.icon-btn.active {
    transform: scale(0.98);
    box-shadow: 0 6px 18px rgba(82, 0, 194, 0.12);
}

/* Placeholder poster style fallback (for data-uri SVG) */
.poster[onerror] {
    background: #f3f3f3 url('data:image/svg+xml;utf8,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%22200%22 height=%22300%22%3E%3Crect width=%22100%25%22 height=%22100%25%22 fill=%22%23f3f3f3%22/%3E%3Ctext x=%2250%25%22 y=%2250%25%22 font-size=%2220%22 text-anchor=%22middle%22 fill=%22%23999%22 dy=%22.3em%22%3ESem imagem%3C/text%3E%3C/svg%3E') center/contain no-repeat;
}

/* ===== Animações e modal ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fadeIn {
    animation: fadeInUp 260ms ease both;
}

/* toggled state for buttons */
.icon-btn.toggled {
    background: linear-gradient(90deg, #ff4d6d, #ff6f91);
    color: #fff;
}

.icon-btn.toggled i {
    color: #fff;
}

/* modal */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 120;
}

.modal[aria-hidden="false"] {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(14, 6, 28, 0.6);
    backdrop-filter: blur(4px);
}

.modal-panel {
    position: relative;
    background: #fff;
    border-radius: 0.6em;
    padding: 1.2rem;
    max-width: 880px;
    width: calc(100% - 2rem);
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(39, 0, 59, 0.3);
    transform-origin: center;
    animation: fadeInUp 200ms ease both;
}

#modal-close {
    position: absolute;
    right: 0.6rem;
    top: 0.6rem;
    background: transparent;
    border: none;
    font-size: 1.1rem;
}

#modal-content .modal-header {
    display: flex;
    gap: 1rem;
}

#modal-content .modal-header img {
    width: 160px;
    height: 240px;
    object-fit: cover;
    border-radius: 0.4em;
}

#modal-content h2 {
    margin: 0 0 0.4rem 0;
}

/* small accessibility tweaks */
.modal-panel:focus {
    outline: none;
}

/* smooth dropdown of suggestions */
.suggestions {
    transition: opacity 160ms ease, transform 160ms ease;
    transform-origin: top left;
}

.suggestions.visible {
    opacity: 1;
    transform: translateY(0);
}

.suggestions {
    opacity: 0;
    transform: translateY(-6px);
}

/* ===== Header / Navbar ===== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 200;
    backdrop-filter: blur(6px);
    background: linear-gradient(180deg, rgba(18, 2, 36, 0.6), rgba(18, 2, 36, 0.4));
    padding: 0.6rem 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.app-header .inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1100px;
    margin: 0 auto;
}

.brand {
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    font-size: 1.05rem;
}

.nav a {
    color: #d9cffb;
    text-decoration: none;
    margin-left: 0.9rem;
    padding: 0.45rem 0.6rem;
    border-radius: 0.45rem;
}

.nav a.active,
.nav a:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
}

/* ===== Mobile hamburger menu ===== */
.nav-toggle{ display:none; background:transparent; border:none; color:#fff; font-size:1.2rem; }

@media screen and (max-width:600px){
    .nav{ position: fixed; top:56px; right:0.6rem; background: rgba(18,2,36,0.98); border-radius:0.6em; padding:0.6rem; box-shadow:0 12px 30px rgba(0,0,0,0.4); opacity:0; transform: translateY(-8px) scale(0.99); transition: opacity 180ms ease, transform 180ms ease; pointer-events:none; z-index:220; min-width:160px; }
    .nav a{ display:block; margin:0.2rem 0; color:#fff; padding:0.45rem 0.6rem; }
    .nav.open{ opacity:1; transform: translateY(0) scale(1); pointer-events:auto; }
    .nav-toggle{ display:inline-block; }
    .nav-backdrop{ position: fixed; inset:0; background: rgba(0,0,0,0.35); z-index:210; }
}

/* suggestions above input */
.suggestions.above{ top: auto; bottom: calc(100% + 0.6em); transform-origin: bottom left; }

/* ===== Responsividade aprimorada para tablet e mobile ===== */

/* Tablet: entre 600px e 980px */
@media screen and (max-width: 980px) and (min-width: 601px) {
    .container {
        padding: 1rem;
        gap: 1rem;
    }
    .main-content {
        padding: 1rem;
        border-radius: 0.6em;
    }
    #movie-name { height:44px; font-size:0.98rem; }
    #search-button { height:44px; min-width:110px; }
    .poster { width:120px; height:180px; }
    .info { gap:0.8rem; }
}

/* Mobile: até 600px */
@media screen and (max-width: 600px) {
    body { background: linear-gradient(180deg, rgba(39,0,59,1) 0%, rgba(82,0,194,1) 100%); }
    .container { padding: 0.9rem; gap: 0.9rem; }

    /* header already responsive; make brand smaller */
    .brand { font-size: 0.98rem; }

    /* Stack the search vertically */
    .search-container { flex-direction: column; align-items: stretch; }
    .input-wrap { order: 0; }
    #movie-name { width:100%; height:48px; font-size:0.98rem; }
    #search-button { width:100%; height:48px; min-width:unset; margin-top:0.6rem; }

    /* Suggestions should expand to full width and be on top of other content */
    .suggestions { position: absolute; left: 0; right: 0; top: calc(100% + 0.4em); max-height: 220px; }

    /* Sidebar becomes horizontal blocks after main - handled by grid change earlier */
    .sidebar { position: relative; top: 0; }

    /* Reduce spacing and sizes in content */
    .main-content { padding: 0.9rem; }
    #result { padding: 0.9rem; }

    .poster { width: 96px; height: 140px; }
    .info { flex-direction: column; gap: 0.6rem; }

    h2 { font-size: 1.05rem; text-align:left; }
    p { font-size: 0.92rem; }

    /* Modal full screen on mobile */
    .modal-panel { width: calc(100% - 1.2rem); max-width: 100%; max-height: calc(100vh - 2rem); border-radius: 0.6em; }
    #modal-content .modal-header img { width: 110px; height: 160px; }

    /* Adjust lists to be thumb-friendly */
    .list { max-height: 200px; }
    .list li { padding: 0.5rem; }

    /* Ensure controls are reachable with touch */
    .controls .icon-btn, .icon-btn { padding: 0.55rem 0.7rem; }
}

/* Very small screens: make font a bit smaller to keep layout */
@media screen and (max-width: 360px) {
    #movie-name { font-size: 0.92rem; }
    #btn-text { font-size: 0.92rem; }
    .brand { font-size: 0.95rem; }
}

/* Improve focus visible on small devices */
@media (pointer: coarse) {
    #search-button:focus, #movie-name:focus { outline: 3px solid rgba(82,0,194,0.14); }
}

/* End responsivity improvements */

/* header actions (favorites badge) */
.header-actions{ display:flex; align-items:center; gap:0.6rem; }
.header-actions a{ color:#fff; text-decoration:none; position:relative; display:inline-flex; align-items:center; padding:0.2rem 0.4rem; }
.badge{ position:absolute; top:-6px; right:-6px; background:#ff4d6d; color:#fff; font-size:0.72rem; padding:0.18rem 0.4rem; border-radius:999px; font-weight:700; }

@media screen and (max-width:600px){
    .header-actions a{ padding:0.15rem; }
    .badge{ top:-4px; right:-4px; }
}