/**
 * Admin Panel v4.0 - Estilos Avançados
 * Design moderno e profissional para todas as funcionalidades
 */

/* ═══════════════════════════════════════════════════════════════
   ANIMAÇÕES GLOBAIS
   ═══════════════════════════════════════════════════════════════ */

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════════════════════════════════
   CONFIRM DIALOG
   ═══════════════════════════════════════════════════════════════ */

.confirm-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: fadeIn 0.2s ease-out;
}

.confirm-dialog {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.3s ease-out;
}

.confirm-dialog-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid #e5e5e7;
}

.confirm-dialog-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #1d1d1f;
}

.confirm-dialog-body {
    padding: 24px;
    color: #1d1d1f;
    line-height: 1.6;
}

.confirm-dialog-actions {
    padding: 16px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    border-top: 1px solid #e5e5e7;
}

/* ═══════════════════════════════════════════════════════════════
   CUSTOM MODAL
   ═══════════════════════════════════════════════════════════════ */

.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
    overflow-y: auto;
}

.custom-modal {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.3s ease-out;
}

.custom-modal-header {
    padding: 24px;
    border-bottom: 1px solid #e5e5e7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.custom-modal-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #1d1d1f;
}

.custom-modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: #86868b;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.custom-modal-close:hover {
    color: #1d1d1f;
}

.custom-modal-body {
    padding: 24px;
}

/* ═══════════════════════════════════════════════════════════════
   EDITOR DE PRIVACIDADE
   ═══════════════════════════════════════════════════════════════ */

.privacy-editor {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px;
    background: #f5f5f7;
    border-bottom: 1px solid #d1d1d6;
    border-radius: 8px 8px 0 0;
    flex-wrap: wrap;
}

.toolbar-btn {
    background: white;
    border: 1px solid #d1d1d6;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    color: #1d1d1f;
}

.toolbar-btn:hover {
    background: #e5e5e7;
    border-color: #a1a1a6;
}

.toolbar-btn:active {
    transform: scale(0.95);
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: #d1d1d6;
    margin: 0 4px;
}

.editor-content {
    min-height: 400px;
    max-height: 500px;
    overflow-y: auto;
    padding: 24px;
    border: 1px solid #d1d1d6;
    border-top: none;
    background: white;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: #1d1d1f;
}

.editor-content:focus {
    outline: none;
    background: #fafafa;
}

.editor-content h2 {
    font-size: 24px;
    font-weight: 600;
    margin: 24px 0 16px;
    color: #1d1d1f;
}

.editor-content h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 20px 0 12px;
    color: #1d1d1f;
}

.editor-content p {
    margin: 12px 0;
}

.editor-content ul, .editor-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.editor-content li {
    margin: 8px 0;
}

.editor-content a {
    color: #0071e3;
    text-decoration: none;
}

.editor-content a:hover {
    text-decoration: underline;
}

.editor-footer {
    padding: 16px;
    background: #f5f5f7;
    border: 1px solid #d1d1d6;
    border-top: none;
    border-radius: 0 0 8px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.editor-status {
    font-size: 13px;
    color: #86868b;
}

.editor-actions {
    display: flex;
    gap: 12px;
}

/* ═══════════════════════════════════════════════════════════════
   GERENCIAMENTO DE LINKS DAS LOJAS
   ═══════════════════════════════════════════════════════════════ */

.store-links-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.link-preview-item {
    padding: 20px;
    background: #f5f5f7;
    border-radius: 12px;
    transition: transform 0.2s;
}

.link-preview-item:hover {
    transform: translateY(-2px);
}

/* ═══════════════════════════════════════════════════════════════
   GERADOR DE QR CODE
   ═══════════════════════════════════════════════════════════════ */

.qr-generator {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.qr-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.qr-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: #f5f5f7;
    border-radius: 12px;
}

.qr-preview {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.qr-preview canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.qr-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════
   GERENCIAMENTO DE USUÁRIOS
   ═══════════════════════════════════════════════════════════════ */

.users-list {
    width: 100%;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.users-table thead {
    background: #f5f5f7;
}

.users-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #1d1d1f;
    border-bottom: 2px solid #d1d1d6;
}

.users-table td {
    padding: 16px;
    border-bottom: 1px solid #e5e5e7;
    font-size: 14px;
    color: #1d1d1f;
}

.users-table tr:hover {
    background: #fafafa;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.role-badge.role-admin {
    background: #ffedd5;
    color: #ea580c;
}

.role-badge.role-editor {
    background: #dbeafe;
    color: #1e40af;
}

.role-badge.role-viewer {
    background: #f3e8ff;
    color: #7c3aed;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    transition: transform 0.2s;
}

.btn-icon:hover {
    transform: scale(1.2);
}

.btn-icon:active {
    transform: scale(0.9);
}

.user-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label span {
    font-size: 15px;
    color: #1d1d1f;
}

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD DE SEGURANÇA
   ═══════════════════════════════════════════════════════════════ */

.security-dashboard {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.security-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-4px);
}

.stat-card:nth-child(2) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-card:nth-child(3) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-card:nth-child(4) {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.stat-icon {
    font-size: 36px;
    opacity: 0.9;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
}

.security-logs-section h3 {
    color: #1d1d1f;
    font-size: 20px;
    font-weight: 600;
}

.security-logs {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.log-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: #fafafa;
    border-left: 4px solid #86868b;
    border-radius: 8px;
    transition: all 0.2s;
}

.log-item:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.log-item.log-success {
    border-left-color: #34c759;
}

.log-item.log-error {
    border-left-color: #ff3b30;
}

.log-item.log-warning {
    border-left-color: #ff9500;
}

.log-item.log-info {
    border-left-color: #0071e3;
}

.log-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.log-content {
    flex: 1;
}

.log-message {
    font-size: 14px;
    color: #1d1d1f;
    margin-bottom: 8px;
    font-weight: 500;
}

.log-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 12px;
    color: #86868b;
}

/* Logs completos */
.security-logs-full {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.logs-filter {
    display: flex;
    gap: 12px;
    align-items: center;
}

.logs-container {
    max-height: 600px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.log-item-detailed {
    background: white;
    border: 1px solid #e5e5e7;
    border-left: 4px solid #86868b;
    border-radius: 8px;
    overflow: hidden;
}

.log-item-detailed.log-success {
    border-left-color: #34c759;
}

.log-item-detailed.log-error {
    border-left-color: #ff3b30;
}

.log-item-detailed.log-warning {
    border-left-color: #ff9500;
}

.log-item-detailed.log-info {
    border-left-color: #0071e3;
}

.log-header {
    padding: 12px 16px;
    background: #fafafa;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e5e7;
}

.log-type {
    font-size: 13px;
    font-weight: 600;
    color: #1d1d1f;
}

.log-time {
    font-size: 12px;
    color: #86868b;
}

.log-body {
    padding: 16px;
}

.log-details {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e5e7;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 12px;
    color: #86868b;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVIDADE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .confirm-dialog,
    .custom-modal {
        width: 95%;
        margin: 20px auto;
    }

    .custom-modal-header h3 {
        font-size: 20px;
    }

    .security-stats {
        grid-template-columns: 1fr;
    }

    .users-table {
        font-size: 12px;
    }

    .users-table th,
    .users-table td {
        padding: 8px;
    }

    .editor-toolbar {
        gap: 2px;
        padding: 8px;
    }

    .toolbar-btn {
        padding: 6px 8px;
        font-size: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 24px;
    }

    .stat-icon {
        font-size: 28px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   LOADING OVERLAY (OPCIONAL)
   ═══════════════════════════════════════════════════════════════ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ═══════════════════════════════════════════════════════════════
   APP CARDS E BOTÕES MODERNOS
   ═══════════════════════════════════════════════════════════════ */

.app-item-modern {
    margin-bottom: 20px;
}

.app-card-modern {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    overflow: hidden;
}

.app-card-modern:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.app-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid #f2f2f7;
}

.app-icon-preview {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.app-icon-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.app-icon-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f7;
    border-radius: 12px;
    font-size: 32px;
}

.app-title-section {
    flex: 1;
    min-width: 0;
}

.app-title {
    font-size: 20px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 0 0 4px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-category {
    font-size: 14px;
    font-weight: 500;
}

.app-actions-modern {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-qr-modern,
.btn-edit-modern,
.btn-delete-modern {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    background: white;
    color: #1d1d1f;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-qr-modern {
    border-color: #34c759;
    color: #34c759;
}

.btn-qr-modern:hover {
    background: #34c759;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.3);
}

.btn-edit-modern {
    border-color: #0071e3;
    color: #0071e3;
}

.btn-edit-modern:hover {
    background: #0071e3;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

.btn-delete-modern {
    border-color: #ff3b30;
    color: #ff3b30;
}

.btn-delete-modern:hover {
    background: #ff3b30;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.3);
}

.app-content {
    padding: 20px;
}

.app-description {
    margin: 0 0 16px 0;
    color: #86868b;
    font-size: 15px;
    line-height: 1.5;
}

.app-status {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.success {
    background: #e8f5e9;
    color: #34c759;
}

.status-badge.info {
    background: #e3f2fd;
    color: #0071e3;
}

.status-badge.warning {
    background: #fff3e0;
    color: #ff9500;
}

.app-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.app-date {
    font-size: 13px;
    color: #86868b;
}

.app-marketing-preview {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    border-top: 1px solid #f2f2f7;
}

.marketing-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.marketing-label {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

/* Responsividade para botões */
@media (max-width: 768px) {
    .app-header {
        flex-wrap: wrap;
    }
    
    .app-actions-modern {
        width: 100%;
        justify-content: flex-start;
    }
    
    .btn-qr-modern,
    .btn-edit-modern,
    .btn-delete-modern {
        flex: 1;
        justify-content: center;
        min-width: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════
   QR BUTTON DROPDOWN - Menu hover para escolher plataforma
   ═══════════════════════════════════════════════════════════════ */

.qr-button-wrapper {
    position: relative;
    display: inline-block;
}

.qr-dropdown-arrow {
    font-size: 10px;
    margin-left: 4px;
    transition: transform 0.3s ease;
}

.qr-button-wrapper:hover .qr-dropdown-arrow {
    transform: rotate(180deg);
}

.qr-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
    animation: dropdownFadeIn 0.2s ease;
    /* Importante: adicionar padding-top invisível para conectar ao botão */
    padding-top: 4px;
    margin-top: -4px;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mostrar menu quando hover no botão OU no menu */
.qr-button-wrapper:hover .qr-dropdown-menu,
.qr-dropdown-menu:hover {
    display: block;
}

.qr-dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #1d1d1f;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid #f2f2f7;
}

.qr-dropdown-item:last-child {
    border-bottom: none;
}

.qr-dropdown-item:hover {
    background: #f5f5f7;
    color: #0071e3;
}

.qr-dropdown-item:active {
    background: #e8e8ed;
}

/* Responsividade para dropdown */
@media (max-width: 768px) {
    .qr-dropdown-menu {
        min-width: 180px;
        left: auto;
        right: 0;
    }
    
    .qr-dropdown-item {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   BOTÃO DE REMOÇÃO DE IMAGEM (garantir funcionalidade)
   ═══════════════════════════════════════════════════════════════ */

.image-remove-btn,
.drop-zone-remove {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    background: rgba(255, 59, 48, 0.95) !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    font-size: 20px !important;
    font-weight: bold !important;
    line-height: 1 !important;
    transition: all 0.3s ease !important;
    z-index: 100 !important;
    pointer-events: auto !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

.image-remove-btn:hover,
.drop-zone-remove:hover {
    background: #ff3b30 !important;
    transform: scale(1.15) !important;
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.5) !important;
}

.image-remove-btn:active,
.drop-zone-remove:active {
    transform: scale(0.95) !important;
}

/* Garantir que imagens na preview não capturem eventos */
.image-preview-modern.has-image img {
    pointer-events: none !important;
}

