/**
 * Sistema Responsivo Mobile-First
 * Breakpoints: mobile <768px, tablet 768-1024px, desktop >1024px
 */

/* ========================================
   VARIÁVEIS CSS E CONFIGURAÇÃO BASE
   ======================================== */

:root {
    /* Breakpoints */
    --breakpoint-mobile: 767px;
    --breakpoint-tablet: 1023px;
    --breakpoint-desktop: 1024px;
    
    /* Espaçamentos Mobile-First */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Touch Targets */
    --touch-target-min: 44px;
    
    /* Grid */
    --grid-gap: 16px;
    --card-padding: 16px;
    
    /* Transições */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* ========================================
   BASE MOBILE-FIRST (< 768px)
   ======================================== */

/* Container responsivo */
.container-responsive {
    width: 100%;
    max-width: 100%;
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
    margin-left: auto;
    margin-right: auto;
}

/* Page Layout */
.page-header {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.filters-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* Spacing utilities */
.space-y-6 > * + * {
    margin-top: 24px;
}

/* Prevenir overflow horizontal */
body {
    overflow-x: hidden;
    width: 100%;
}

* {
    max-width: 100%;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* ========================================
   SISTEMA DE CARDS RESPONSIVOS
   ======================================== */

/* Card Base */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: var(--card-padding);
    margin-bottom: var(--spacing-md);
    width: 100%;
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-subtitle {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.card-empty {
    text-align: center;
    color: #6b7280;
    padding: var(--spacing-lg);
}

.card-footer {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid #e5e7eb;
}

.card-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    flex-wrap: wrap;
}

/* Card Field (para exibir dados) */
.card-field {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) 0;
}

.field-label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
    flex-shrink: 0;
}

.field-value {
    font-size: 14px;
    color: #1f2937;
    text-align: right;
    word-break: break-word;
}

/* Card Status Badge */
.card-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.status-active {
    background-color: #d1fae5;
    color: #065f46;
}

.status-pending {
    background-color: #fef3c7;
    color: #92400e;
}

.status-blocked {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-paused {
    background-color: #e0e7ff;
    color: #3730a3;
}

.status-rejected {
    background-color: #fee2e2;
    color: #991b1b;
}

/* ========================================
   CARDS ESPECÍFICOS - ADMIN USERS
   ======================================== */

/* Card de Usuário Admin */
.admin-user-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: var(--card-padding);
    margin-bottom: var(--spacing-md);
    width: 100%;
    overflow: hidden;
}

.admin-user-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-md);
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.admin-user-card-main {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex: 1;
    min-width: 0;
}

.admin-user-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #6b7280;
    flex-shrink: 0;
    font-size: 18px;
}

.admin-user-card-info {
    flex: 1;
    min-width: 0;
}

.admin-user-card-name {
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 4px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 16px;
}

.admin-user-card-email {
    font-size: 13px;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
}

.admin-user-card-role {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.admin-user-card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
    margin: var(--spacing-md) 0;
    padding: var(--spacing-sm) 0;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
}

.admin-user-card-stat {
    text-align: center;
}

.admin-user-card-stat-label {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.admin-user-card-stat-value {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.admin-user-card-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.admin-user-card-actions .btn-primary,
.admin-user-card-actions .btn-secondary,
.admin-user-card-actions .btn-success,
.admin-user-card-actions .btn-danger {
    width: 100%;
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    border-radius: 8px;
    transition: all var(--transition-fast);
    padding: 12px 16px;
}

.admin-user-card-actions .btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
}

.admin-user-card-actions .btn-disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

/* Garantir que botões sejam sempre visíveis */
.admin-user-card-actions button,
.admin-user-card-actions a {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    pointer-events: auto !important;
}

/* ========================================
   CARDS ESPECÍFICOS
   ======================================== */

/* Card de Anúncio */
.ad-card {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: var(--spacing-md);
    align-items: start;
}

.ad-card-image {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    background-color: #f3f4f6;
}

.ad-card-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.ad-card-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.ad-card-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ad-card-stat-label {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ad-card-stat-value {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

/* Card de Usuário */
.user-card-main {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex: 1;
    min-width: 0;
}

.user-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #6b7280;
    flex-shrink: 0;
}

.user-card-info {
    flex: 1;
    min-width: 0;
}

.user-card-name {
    font-weight: 600;
    color: #1f2937;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-card-email {
    font-size: 13px;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-card-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--spacing-xs);
}

.user-card-role {
    font-size: 12px;
    color: #6b7280;
}

/* Paginação */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    margin-top: var(--spacing-lg);
}

.pagination-dots {
    color: #6b7280;
    font-size: 14px;
}

/* Mensagens */
.error-message {
    background-color: #fee2e2;
    color: #991b1b;
    padding: var(--spacing-md);
    border-radius: 8px;
    margin-bottom: var(--spacing-lg);
}

/* Card de Estatística */
.stats-card {
    text-align: center;
    padding: var(--spacing-lg);
}

.stats-card-value {
    font-size: 32px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.stats-card-label {
    font-size: 14px;
    color: #6b7280;
    margin-top: var(--spacing-xs);
}

.stats-card-change {
    font-size: 12px;
    margin-top: var(--spacing-xs);
}

.stats-card-change.positive {
    color: #059669;
}

.stats-card-change.negative {
    color: #dc2626;
}

/* ========================================
   GRID RESPONSIVO
   ======================================== */

.grid-responsive {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--grid-gap);
}

.grid-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* ========================================
   BOTÕES TOUCH-FRIENDLY
   ======================================== */

.btn-mobile {
    min-height: var(--touch-target-min);
    padding: 12px 20px;
    font-size: 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background-color: #dc2626;
    color: white;
}

.btn-primary:hover {
    background-color: #b91c1c;
}

.btn-secondary {
    background-color: #f3f4f6;
    color: #1f2937;
}

.btn-secondary:hover {
    background-color: #e5e7eb;
}

.btn-success {
    background-color: #059669;
    color: white;
}

.btn-danger {
    background-color: #dc2626;
    color: white;
}

.btn-block {
    width: 100%;
    display: flex;
}

.btn-sm {
    min-height: 36px;
    padding: 8px 16px;
    font-size: 14px;
}

.btn-lg {
    min-height: 52px;
    padding: 16px 24px;
    font-size: 18px;
}

/* ========================================
   FORMULÁRIOS MOBILE-FIRST
   ======================================== */

.form-mobile {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.form-label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.form-input,
.form-select,
.form-textarea {
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px; /* Evita zoom no iOS */
    min-height: var(--touch-target-min);
    width: 100%;
    transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
}

.form-helper {
    font-size: 13px;
    color: #6b7280;
    margin-top: var(--spacing-xs);
}

.form-error {
    font-size: 13px;
    color: #dc2626;
    margin-top: var(--spacing-xs);
}

/* Checkbox e Radio Touch-Friendly */
.form-checkbox,
.form-radio {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.form-check-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    min-height: var(--touch-target-min);
}

/* ========================================
   TABELAS → CARDS (Mobile)
   ======================================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Ocultar tabelas em mobile, mostrar cards */
.table-desktop {
    display: none;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: var(--spacing-lg);
}

.table-full {
    width: 100%;
    border-collapse: collapse;
}

.table-full th {
    padding: 12px 24px;
    text-align: left;
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.table-full td {
    padding: 16px 24px;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
}

.table-full tr:hover {
    background-color: #f9fafb;
}

/* Tabela - Células específicas */
.table-empty {
    text-align: center;
    padding: 48px 24px;
    color: #6b7280;
}

.table-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #6b7280;
    flex-shrink: 0;
}

.table-user-info {
    flex: 1;
    min-width: 0;
}

.table-user-name {
    font-weight: 500;
    color: #1f2937;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-user-email {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-role {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.role-admin {
    background-color: #ede9fe;
    color: #7c3aed;
}

.role-advertiser {
    background-color: #dbeafe;
    color: #2563eb;
}

.role-user {
    background-color: #f3f4f6;
    color: #374151;
}

.table-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.table-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.table-action-link {
    color: #2563eb;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.table-action-link:hover {
    text-decoration: underline;
}

.table-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    padding: 0;
}

.table-action-success {
    color: #059669;
}

.table-action-danger {
    color: #dc2626;
}

.table-action-btn:hover {
    text-decoration: underline;
}

.card-list-mobile {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* ========================================
   NAVEGAÇÃO MOBILE
   ======================================== */

.mobile-menu-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
}

.mobile-menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transition: left var(--transition-normal);
    z-index: 1000;
    overflow-y: auto;
}

.mobile-menu.active {
    left: 0;
}

.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-menu-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-menu-close {
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-menu-nav {
    padding: var(--spacing-md);
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    padding: 12px var(--spacing-md);
    color: #1f2937;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color var(--transition-fast);
    min-height: var(--touch-target-min);
}

.mobile-menu-item:hover {
    background-color: #f3f4f6;
}

.mobile-menu-item.active {
    background-color: #fee2e2;
    color: #dc2626;
    font-weight: 500;
}

/* ========================================
   MODAIS RESPONSIVOS
   ======================================== */

.modal-mobile {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 0;
}

.modal-mobile.active {
    display: flex;
}

.modal-content-mobile {
    background: white;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-header-mobile {
    padding: var(--spacing-lg);
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.modal-body-mobile {
    padding: var(--spacing-lg);
}

.modal-footer-mobile {
    padding: var(--spacing-lg);
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: var(--spacing-sm);
    position: sticky;
    bottom: 0;
    background: white;
}

/* ========================================
   UTILITÁRIOS MOBILE
   ======================================== */

.hide-mobile {
    display: none !important;
}

.show-mobile {
    display: block !important;
}

.text-center-mobile {
    text-align: center;
}

.full-width-mobile {
    width: 100%;
}

.no-padding-mobile {
    padding: 0 !important;
}

.no-margin-mobile {
    margin: 0 !important;
}

/* Espaçamentos Mobile */
.mt-mobile-sm { margin-top: var(--spacing-sm); }
.mt-mobile-md { margin-top: var(--spacing-md); }
.mt-mobile-lg { margin-top: var(--spacing-lg); }

.mb-mobile-sm { margin-bottom: var(--spacing-sm); }
.mb-mobile-md { margin-bottom: var(--spacing-md); }
.mb-mobile-lg { margin-bottom: var(--spacing-lg); }

.p-mobile-sm { padding: var(--spacing-sm); }
.p-mobile-md { padding: var(--spacing-md); }
.p-mobile-lg { padding: var(--spacing-lg); }

/* ========================================
   TABLET (768px - 1024px)
   ======================================== */

@media (min-width: 768px) {
    .container-responsive {
        max-width: 720px;
        padding-left: var(--spacing-lg);
        padding-right: var(--spacing-lg);
    }
    
    .page-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .filters-container {
        flex-direction: row;
        align-items: center;
        width: auto;
    }
    
    .grid-responsive {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ad-card {
        grid-template-columns: 100px 1fr;
    }
    
    .ad-card-image {
        width: 100px;
        height: 100px;
    }
    
    .ad-card-stats {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Mostrar tabelas em tablet */
    .table-desktop {
        display: table;
    }
    
    .card-list-mobile {
        display: none;
    }
    
    /* Ocultar menu mobile */
    .mobile-menu-trigger {
        display: none;
    }
    
    /* Modal centralizado */
    .modal-mobile {
        align-items: center;
        padding: var(--spacing-lg);
    }
    
    .modal-content-mobile {
        border-radius: 16px;
        max-width: 600px;
        max-height: 80vh;
    }
    
    .hide-tablet {
        display: none !important;
    }
    
    .show-tablet {
        display: block !important;
    }
}

/* ========================================
   DESKTOP (> 1024px)
   ======================================== */

@media (min-width: 1024px) {
    .container-responsive {
        max-width: 1200px;
    }
    
    .grid-responsive {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .ad-card {
        grid-template-columns: 120px 1fr;
    }
    
    .ad-card-image {
        width: 120px;
        height: 120px;
    }
    
    .modal-content-mobile {
        max-width: 800px;
    }
    
    .hide-desktop {
        display: none !important;
    }
    
    .show-desktop {
        display: block !important;
    }
}

/* ========================================
   ACESSIBILIDADE E PERFORMANCE
   ======================================== */

/* Reduzir animações para usuários que preferem */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Melhorar contraste em modo escuro */
@media (prefers-color-scheme: dark) {
    .card {
        background: #1f2937;
        color: #f3f4f6;
    }
    
    .card-title {
        color: #f3f4f6;
    }
    
    .field-label {
        color: #9ca3af;
    }
    
    .field-value {
        color: #e5e7eb;
    }
}

/* Touch device optimizations */
.touch-device .btn-mobile:hover {
    transform: none;
}

.touch-device .ad-card:hover {
    transform: none;
}

/* Lazy loading placeholder */
.lazy-loading {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}