@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap');

:root {
    --primary-color: #004aad;
    --secondary-color: #f0f2f5;
    --accent-color: #ffc107;
    --text-color: #333;
    --white-color: #fff;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --inactive-color: #6c757d;
    --warning-color: #ffc107;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: var(--secondary-color);
    color: var(--text-color);
}

body.no-scroll {
    overflow: hidden;
}

/* --- BADGES DE SITUAÇÃO --- */
.status-badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-badge.ativo {
    background-color: #d4edda;
    color: #155724;
}

.status-badge.inativo {
    background-color: #f8d7da;
    color: #721c24;
}

.status-badge.Ativo {
    background-color: #d4edda;
    color: #155724;
}

.status-badge.Inativo {
    background-color: #f8d7da;
    color: #721c24;
}

.status-badge.Inadimplente {
    background-color: #fff3cd;
    color: #856404;
}

/* --- GALERIA DE FOTOS --- */
.partner-gallery {
    position: relative;
    width: 100%;
    height: 240px;
    overflow: hidden;
    background: #f5f5f5;
}

.gallery-container {
    display: flex;
    transition: transform 0.3s ease;
    height: 100%;
}

.gallery-image {
    min-width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.3s, background 0.3s;
    z-index: 10;
}

.partner-card:hover .gallery-nav,
.partner-card.expanded .gallery-nav {
    opacity: 1;
}

.gallery-nav:hover {
    background: rgba(0, 0, 0, 0.7);
}

.gallery-nav.prev {
    left: 10px;
}

.gallery-nav.next {
    right: 10px;
}

.gallery-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 10;
}

.gallery-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: background 0.3s, transform 0.3s;
}

.gallery-dot.active {
    background: white;
    transform: scale(1.2);
}

/* --- TELA DE LOGIN --- */
#login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: #f5f5f5 !important;
    background-color: #f5f5f5 !important;
    background-image: none !important;
}

@media (prefers-color-scheme: dark) {
    #login-container {
        background: #1a1a1a !important;
        background-color: #1a1a1a !important;
        background-image: none !important;
    }
}

.login-box {
    background: var(--white-color);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.login-header {
    background-color: var(--primary-color);
    padding: 2rem 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 140px;
}

.login-logo {
    max-width: 320px;
    max-height: 130px;
    height: auto;
    display: block;
    object-fit: contain;
}

.login-body {
    padding: 2rem 2.5rem 2.5rem;
    text-align: center;
}

.login-box h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.input-group {
    margin-bottom: 1rem;
}

.input-group input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.login-box button {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 5px;
    background-color: var(--primary-color);
    color: var(--white-color);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.login-box button:hover {
    background-color: #003a8c;
}

.login-box a {
    display: block;
    margin-top: 1rem;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
}

.login-box a:hover {
    text-decoration: underline;
}

.error-message {
    color: var(--danger-color);
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 1rem;
}

.loading-message {
    text-align: center;
    padding: 2rem;
    color: #666;
}

/* --- ESTRUTURA DA APLICAÇÃO --- */
#app-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--primary-color);
    color: var(--white-color);
    display: flex;
    flex-direction: column;
    padding-top: 1rem;
    flex-shrink: 0;
    transition: transform 0.3s ease-in-out;
}

.sidebar-header {
    padding: 1.5rem 1rem;
    text-align: center;
    font-size: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
}

.sidebar-logo {
    max-width: 230px;
    max-height: 95px;
    height: auto;
    display: block;
    object-fit: contain;
}

.sidebar nav ul {
    list-style: none;
    padding: 1rem 0;
}

.sidebar nav li a {
    display: block;
    padding: 1rem 1.5rem;
    color: var(--white-color);
    text-decoration: none;
    transition: background 0.3s;
    border-left: 3px solid transparent;
}

.sidebar nav li a:hover, .sidebar nav li a.active {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent-color);
}

.sidebar nav li a i {
    margin-right: 1rem;
}

#logout-btn {
    cursor: pointer;
}

.content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.add-btn {
    background-color: var(--primary-color);
    color: var(--white-color);
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.add-btn:hover {
    background-color: #003a8c;
}

.add-btn i {
    margin-right: 0.5rem;
}

/* --- PÁGINA INICIAL --- */
.partners-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.partner-card {
    background: var(--white-color);
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    align-self: start;
}

.partner-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.12);
}

.partner-card .partner-info-header {
    padding: 1rem;
    font-weight: 600;
}

.partner-card .partner-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-in-out, padding 0.5s ease-in-out;
    padding: 0 1rem;
}

.partner-card.expanded .partner-details {
    max-height: 500px;
    padding: 1rem;
    border-top: 1px solid #eee;
}

.partner-details p, .partner-details ul {
    margin-bottom: 0.75rem;
}

.partner-details ul {
    list-style: none;
    padding-left: 0;
}

.partner-details ul li {
    background: var(--secondary-color);
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.partner-details strong {
    color: var(--primary-color);
}

.partner-details .discount-btn {
    display: inline-block;
    width: 100%;
    text-align: center;
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--success-color);
    color: var(--white-color);
    text-decoration: none;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 1rem;
}

.partner-details .discount-btn:hover {
    background: #218838;
}

.partner-details .discount-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* --- TABELAS (USUÁRIOS E PARCEIROS) --- */
.table-container {
    background: var(--white-color);
    border-radius: 8px;
    overflow-x: auto;
    padding: 1.5rem;
}

.search-input {
    width: 100%;
    max-width: 400px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 1.5rem;
    border-radius: 5px;
    border: 1px solid #ddd;
    font-size: 0.95rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background: var(--secondary-color);
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    margin-right: 10px;
    font-size: 1.1rem;
    padding: 0.3rem;
}

.edit-btn { color: var(--primary-color); }
.delete-btn { color: var(--danger-color); }

/* --- PÁGINA PERFIL E CONTATO --- */
.profile-card, .contact-card {
    background: var(--white-color);
    padding: 2rem;
    border-radius: 8px;
    max-width: 700px;
}

.profile-card h3, .contact-card h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.profile-card p {
    margin-bottom: 0.75rem;
}

.profile-card hr {
    margin: 1.5rem 0;
    border: 0;
    border-top: 1px solid #eee;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="color"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

#change-password-form input {
    display: block;
    width: 100%;
    max-width: 300px;
    padding: 0.5rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    border: 1px solid #ddd;
}

#change-password-form button,
#settings-form button {
    background-color: var(--primary-color);
    color: var(--white-color);
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#change-password-form button:hover,
#settings-form button:hover {
    background-color: #003a8c;
}

.feedback-message {
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 1rem;
}

#profile-status.Ativo { color: var(--success-color); font-weight: bold; }
#profile-status.Inativo { color: var(--inactive-color); font-weight: bold; }
#profile-status.Inadimplente { color: var(--danger-color); font-weight: bold; }

.contact-info {
    margin-top: 1.5rem;
}

.contact-info a {
    font-size: 1.2rem;
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.contact-info a:hover {
    color: var(--primary-color);
}

.contact-info i {
    font-size: 2rem;
    margin-right: 1rem;
    color: var(--primary-color);
}

.contact-info .fa-whatsapp { color: #25D366; }
.contact-info .fa-instagram { color: #C13584; }

/* --- MODAIS --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 2rem;
    border: 1px solid #888;
    width: 90%;
    max-width: 600px;
    border-radius: 10px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close-btn {
    color: #aaa;
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
}

.close-btn:hover {
    color: #000;
}

#partner-form input, #partner-form select, #partner-form textarea,
#user-form input, #user-form select {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: 5px;
    border: 1px solid #ddd;
}

#partner-form button, #user-form button {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#partner-form button:hover, #user-form button:hover {
    background-color: #003a8c;
}

#add-service-btn {
    background: var(--accent-color) !important;
    color: var(--text-color) !important;
    margin: 0.5rem 0;
}

#add-service-btn:hover {
    background: #e0a800 !important;
}

.service-field-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.service-field-group input {
    margin-bottom: 0;
    flex-grow: 1;
}

.remove-service-btn {
    background-color: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding-bottom: 2px;
    transition: background-color 0.3s;
}

.remove-service-btn:hover {
    background-color: #c82333;
}

.qr-modal-content {
    max-width: 350px;
    text-align: center;
}

.qr-modal-content h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

#qr-canvas {
    width: 250px !important;
    height: 250px !important;
    margin: 0 auto;
    display: block;
}

#qr-timer {
    font-size: 1.1rem;
    color: var(--primary-color);
    font-weight: bold;
}

/* --- PREVIEW DE MÚLTIPLAS FOTOS NO MODAL --- */
.photo-preview-item {
    position: relative;
    display: inline-block;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.photo-preview-img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 5px;
    border: 2px solid #ddd;
}

.photo-preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- MODAL DE IMPORTAÇÃO EM LOTE --- */
.import-modal-content {
    max-width: 800px;
}

.import-header {
    margin-bottom: 1.5rem;
}

.import-instructions {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary-color);
}

.import-instructions h4 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.import-instructions ul {
    margin: 0.5rem 0 0 1.5rem;
    font-size: 0.9rem;
}

.import-instructions li {
    margin-bottom: 0.3rem;
}

.import-example {
    background: #fff;
    border: 1px solid #ddd;
    padding: 0.75rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    white-space: pre;
    margin-top: 0.5rem;
}

.import-textarea {
    width: 100%;
    min-height: 250px;
    padding: 1rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 1rem;
}

.import-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.import-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 5px;
}

.import-info-item {
    font-size: 0.9rem;
}

.import-info-label {
    color: #666;
    margin-right: 0.5rem;
}

.import-info-value {
    font-weight: bold;
    color: var(--primary-color);
}

.import-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.button-secondary {
    background: #6c757d;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.button-secondary:hover {
    background: #5a6268;
}

.import-progress {
    margin-top: 1.5rem;
    display: none;
}

.import-progress.active {
    display: block;
}

.progress-bar-container {
    width: 100%;
    height: 30px;
    background: #e9ecef;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
}

.import-result {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 5px;
    display: none;
}

.import-result.active {
    display: block;
}

.import-result.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.import-result.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.import-result h4 {
    margin-bottom: 0.5rem;
}

.import-errors-list {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.import-error-item {
    padding: 0.5rem;
    background: white;
    border-left: 3px solid var(--danger-color);
    margin-bottom: 0.5rem;
    border-radius: 3px;
}

.mobile-header {
    display: none;
}

/* ========================================================================= */
/* --- ESTILOS PARA DISPOSITIVOS MÓVEIS (RESPONSIVO) --- */
/* ========================================================================= */
@media (max-width: 768px) {
    #app-container {
        display: block;
    }

    .content {
        padding: 1rem;
        padding-top: 5rem;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 1100;
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1099;
        display: none;
    }
    
    .mobile-overlay.active {
        display: block;
    }

    .mobile-header {
        display: flex;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        background-color: var(--primary-color);
        color: var(--white-color);
        padding: 1rem;
        z-index: 1000;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }

    .hamburger-btn {
        background: none;
        border: none;
        color: var(--white-color);
        font-size: 1.5rem;
        cursor: pointer;
        margin-right: 1rem;
    }

    .mobile-page-title {
        font-size: 1.2rem;
        font-weight: 600;
    }
    
    .table-container {
        padding: 0;
        background: none;
        overflow-x: hidden;
    }

    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        border: 1px solid #ddd;
        border-radius: 8px;
        margin-bottom: 1rem;
        background: var(--white-color);
        padding: 1rem;
    }
    
    td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
        text-align: right;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        min-height: 2.5rem;
    }
    
    td:before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        text-align: left;
    }
    
    td:last-child {
        border-bottom: 0;
    }
    
    .action-btn {
        font-size: 1.3rem;
        padding: 0.5rem;
    }

    .partners-grid {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .login-box {
        padding: 0;
        margin: 0 1rem;
    }

    .profile-card, .contact-card {
        padding: 1.5rem;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    /* Ocultar setas no mobile - swipe apenas */
    .gallery-nav {
        display: none !important;
    }
}