/* ========================================
   RESET E VARIÁVEIS
   ======================================== */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-card: #ffffff;
    --bg-overlay: rgba(0, 0, 0, 0.75);
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   GRID DE FILMES
   ======================================== */
.mpf-filmes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
    padding: 24px 0;
    max-width: 1400px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .mpf-filmes-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 16px;
        padding: 16px;
    }
}

/* ========================================
   CARDS DE FILMES
   ======================================== */
.mpf-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.mpf-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.mpf-card-header {
    position: relative;
    width: 100%;
    padding-top: 150%;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    overflow: hidden;
}

.mpf-card-header img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.mpf-card:hover .mpf-card-header img {
    transform: scale(1.05);
}

.mpf-no-poster {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-light);
    font-size: 14px;
    text-align: center;
}

.mpf-card-body {
    padding: 16px;
}

.mpf-card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 8px 0;
    line-height: 1.4;
    color: var(--text-primary);
    min-height: 42px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mpf-check-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #10b981;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    margin-left: 6px;
    flex-shrink: 0;
    vertical-align: middle;
}

.mpf-card-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
    min-height: 40px;
}

.mpf-year {
    display: inline-block;
    font-weight: 500;
    color: var(--text-primary);
}

.mpf-genre {
    display: block;
    margin-top: 4px;
    color: var(--text-light);
}

.mpf-expand-btn {
    width: 100%;
    padding: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.mpf-expand-btn:hover {
    background: var(--primary-hover);
}

.mpf-expand-btn:active {
    transform: scale(0.98);
}

/* ========================================
   MODAL
   ======================================== */
.mpf-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mpf-modal.mpf-modal-open {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 768px) {
    .mpf-modal {
        padding: 20px 16px;
        align-items: flex-start;
        overflow-y: auto;
    }
}

.mpf-modal-content {
    background: white;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: var(--shadow-xl);
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mpf-modal.mpf-modal-open .mpf-modal-content {
    transform: scale(1) translateY(0);
}

@media (max-width: 768px) {
    .mpf-modal-content {
        max-height: none;
        border-radius: var(--radius-lg);
    }
}

/* ========================================
   BOTÃO FECHAR
   ======================================== */
.mpf-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.mpf-modal-close:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
    transform: rotate(90deg);
}

@media (max-width: 768px) {
    .mpf-modal-close {
        top: 16px;
        right: 16px;
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
}

/* ========================================
   CONTEÚDO DO MODAL
   ======================================== */
.mpf-modal-body {
    padding: 60px 40px 40px 40px;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .mpf-modal-body {
        padding: 50px 16px 24px 16px;
    }
}

.mpf-modal-content img {
    width: 220px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    float: left;
    margin: 0 32px 24px 0;
    border: 1px solid var(--border-color);
}

@media (max-width: 768px) {
    .mpf-modal-content img {
        width: 200px;
        float: none;
        display: block;
        margin: 0 auto 24px auto;
        box-shadow: var(--shadow-lg);
    }
}

.mpf-modal-content h2 {
    margin: 0 0 8px 0;
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.5px;
}

@media (max-width: 768px) {
    .mpf-modal-content h2 {
        font-size: 24px;
        text-align: center;
        margin-bottom: 12px;
        line-height: 1.3;
    }
}

/* ========================================
   TÍTULO ORIGINAL
   ======================================== */
.mpf-modal-original-title {
    font-size: 18px !important;
    color: var(--text-secondary) !important;
    font-style: italic !important;
    margin: 0 0 16px 0 !important;
    padding: 0 !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    text-align: left !important;
    background: none !important;
    text-shadow: none !important;
    border: none !important;
}

@media (max-width: 768px) {
    .mpf-modal-original-title {
        font-size: 16px !important;
        text-align: center !important;
        margin-bottom: 14px !important;
        line-height: 1.5 !important;
    }
}

/* ========================================
   SUBTÍTULO (ANO + GÊNEROS)
   ======================================== */
.mpf-modal-subtitle {
    font-size: 15px !important;
    color: var(--text-light) !important;
    margin: 0 0 24px 0 !important;
    padding: 0 0 16px 0 !important;
    border-bottom: 1px solid var(--border-color) !important;
    font-weight: 400 !important;
    line-height: 1.5 !important;
    text-align: left !important;
    background: none !important;
    text-shadow: none !important;
}

@media (max-width: 768px) {
    .mpf-modal-subtitle {
        font-size: 14px !important;
        text-align: center !important;
        padding-bottom: 14px !important;
        margin-bottom: 20px !important;
        line-height: 1.6 !important;
        word-wrap: break-word !important;
    }
}

/* ========================================
   INFORMAÇÕES DETALHADAS
   ======================================== */
.mpf-modal-content p {
    margin: 0 0 16px 0;
    line-height: 1.6;
    color: var(--text-secondary);
    font-size: 15px;
}

.mpf-modal-content p strong {
    color: var(--text-primary);
    font-weight: 600;
    display: inline-block;
    min-width: 100px;
}

.mpf-modal-content p:last-child {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .mpf-modal-content p {
        font-size: 15px;
        margin-bottom: 16px;
        line-height: 1.7;
    }
    
    .mpf-modal-content p strong {
        display: block;
        margin-bottom: 6px;
        min-width: auto;
        font-size: 14px;
        color: var(--text-primary);
        font-weight: 600;
    }
    
    /* Sinopse com destaque no mobile */
    .mpf-modal-content p:last-child {
        background: #f9fafb;
        padding: 16px;
        border-radius: var(--radius-md);
        margin-bottom: 0;
        border-left: 3px solid var(--primary-color);
    }
}

/* Clear floats */
.mpf-modal-body::after {
    content: "";
    display: table;
    clear: both;
}

/* ========================================
   SEÇÃO DE ADMINISTRAÇÃO
   ======================================== */
.mpf-add-movie {
    background: white;
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    max-width: 1000px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .mpf-add-movie {
        padding: 20px;
        margin: 0 16px;
    }
}

.mpf-admin-header {
    margin-bottom: 32px;
}

.mpf-admin-header h3 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.mpf-admin-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 15px;
}

/* ========================================
   BUSCA
   ======================================== */
.mpf-search-container {
    position: relative;
    margin-bottom: 32px;
}

.mpf-search-input-group {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

#mpf-search {
    flex: 1;
    padding: 12px 16px;
    font-size: 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
    background: white;
}

#mpf-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.mpf-search-button {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.mpf-search-button:hover {
    background: var(--primary-hover);
}

.mpf-search-button:active {
    transform: scale(0.98);
}

.mpf-search-icon {
    font-size: 16px;
}

@media (max-width: 768px) {
    .mpf-search-input-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .mpf-search-button {
        width: 100%;
        justify-content: center;
    }
}

.mpf-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    max-height: 600px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
}

.mpf-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background: #f9fafb;
    position: sticky;
    top: 0;
    z-index: 10;
}

.mpf-results-header strong {
    color: var(--text-primary);
    font-size: 14px;
}

.mpf-close-results {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mpf-close-results:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

.mpf-results-list {
    padding: 0;
}

.mpf-result {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.mpf-result:last-child {
    border-bottom: none;
}

.mpf-result:hover {
    background: #f9fafb;
}

.mpf-result img {
    width: 50px;
    height: 75px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    border: 1px solid var(--border-color);
}

.mpf-result-info {
    flex: 1;
    min-width: 0;
}

.mpf-result-info strong {
    display: block;
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-weight: 600;
}

.mpf-result-year {
    display: inline-block;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.mpf-result-overview {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.mpf-result .mpf-add {
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    margin-left: auto;
    flex-shrink: 0;
    align-self: flex-start;
}

.mpf-result .mpf-add:hover {
    background: var(--primary-hover);
}

.mpf-result .mpf-add:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .mpf-result {
        flex-direction: column;
        gap: 12px;
    }
    
    .mpf-result img {
        align-self: center;
    }
    
    .mpf-result .mpf-add {
        width: 100%;
        margin-left: 0;
    }
    
    .mpf-search-results {
        max-height: 500px;
    }
}

.mpf-loading,
.mpf-no-results,
.mpf-error {
    padding: 32px 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.mpf-error {
    color: var(--danger-color);
}

.mpf-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.mpf-loading::before {
    content: "";
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========================================
   LISTA DE FILMES CADASTRADOS
   ======================================== */
.mpf-movie-list-container {
    margin-top: 32px;
}

.mpf-movie-list-container h4 {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.mpf-movie-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mpf-movie-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    background: white;
    transition: var(--transition);
    gap: 16px;
}

.mpf-movie-item:hover {
    background: #f9fafb;
    border-color: var(--text-light);
}

.mpf-movie-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.mpf-movie-thumb {
    width: 40px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.mpf-movie-year {
    color: var(--text-light);
    font-weight: normal;
    margin-left: 8px;
}

.mpf-movie-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.mpf-toggle-watched {
    padding: 8px 16px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
}

.mpf-toggle-watched:hover {
    background: var(--danger-hover);
}

.mpf-toggle-watched.watched {
    background: #10b981;
}

.mpf-toggle-watched.watched:hover {
    background: #059669;
}

.mpf-toggle-watched:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.mpf-delete {
    padding: 8px 16px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
}

.mpf-delete:hover {
    background: var(--danger-hover);
}

.mpf-delete:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .mpf-movie-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .mpf-movie-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .mpf-toggle-watched,
    .mpf-delete {
        width: 100%;
    }
}

/* ========================================
   ESTADOS VAZIOS
   ======================================== */
.mpf-empty-state,
.mpf-empty-list {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

/* ========================================
   SCROLLBAR PERSONALIZADO
   ======================================== */
.mpf-modal-content::-webkit-scrollbar,
.mpf-search-results::-webkit-scrollbar {
    width: 8px;
}

.mpf-modal-content::-webkit-scrollbar-track,
.mpf-search-results::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.mpf-modal-content::-webkit-scrollbar-thumb,
.mpf-search-results::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.mpf-modal-content::-webkit-scrollbar-thumb:hover,
.mpf-search-results::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ========================================
   UTILITÁRIOS
   ======================================== */
@media (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}