/**
 * GrobTV - Painel de Revenda IPTV
 * Design Minimalista e Elegante
 */

/* ========================================
   RESET E VARIÁVEIS
   ======================================== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #1e293b;
    --dark-light: #334155;
    --gray: #64748b;
    --gray-light: #cbd5e1;
    --gray-lighter: #f1f5f9;
    --white: #ffffff;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
    --shadow-xl: 0 12px 32px rgba(0, 0, 0, 0.2);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 14px;
}

/* ========================================
   TELA DE LOGIN
   ======================================== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 48px;
    width: 100%;
    max-width: 420px;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.login-logo p {
    color: var(--gray);
    font-size: 13px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-block {
    width: 100%;
}

/* ========================================
   DASHBOARD
   ======================================== */
.dashboard {
    display: none;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dashboard.active {
    display: block;
}

/* Navbar */
.navbar {
    background: var(--white);
    box-shadow: var(--shadow-sm);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-brand h2 {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.navbar-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-meta-label {
    font-size: 12px;
    color: var(--gray);
}

.navbar-meta-value {
    font-weight: 700;
    color: var(--dark);
}

.navbar-credits-value {
    color: var(--primary);
    font-size: 18px;
}

.navbar-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-whatsapp {
    background: #25d366;
    color: #fff;
}

.btn-whatsapp:hover {
    background: #1ebe57;
    color: #fff;
}

.clients-mobile-list {
    display: none;
}

.badge-referral {
    background: #7c3aed;
    color: #fff;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 12px;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-lighter);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-size: 18px;
}

.btn-icon:hover {
    background: var(--gray-light);
    transform: scale(1.1);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-secondary {
    background: var(--gray-lighter);
    color: var(--dark);
}

.btn-secondary:hover {
    background: var(--gray-light);
}

/* Container Principal */
.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* Page Header */
.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
}

.page-header p {
    color: var(--gray);
    font-size: 16px;
}

/* Alertas */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Cards de Estatísticas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stat-card.active {
    border-color: var(--primary);
    border-width: 3px;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.5), 0 0 0 4px rgba(99, 102, 241, 0.1);
    transform: translateY(-4px);
    background: var(--white);
}

.stat-card.active::before {
    width: 8px;
    background: var(--primary);
}

.stat-card.active .stat-title {
    color: var(--primary);
    font-weight: 700;
}

.stat-card.active .stat-value {
    color: var(--primary);
    font-weight: 700;
}

.stat-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
}

.stat-card.green::before {
    background: linear-gradient(180deg, var(--secondary), #059669);
}

.stat-card.orange::before {
    background: linear-gradient(180deg, var(--warning), #d97706);
}

.stat-card.red::before {
    background: linear-gradient(180deg, var(--danger), #dc2626);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-title {
    font-size: 14px;
    color: var(--gray-dark);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(99, 102, 241, 0.2));
}

.stat-card.green .stat-icon {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.2));
}

.stat-card.orange .stat-icon {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.2));
}

.stat-card.red .stat-icon {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.2));
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--dark);
}

/* Card de Conteúdo */
.card {
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 24px;
    border-bottom: 1px solid var(--gray-lighter);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

.card-body {
    padding: 24px;
}

/* Toolbar de Ações */
.toolbar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    outline: none;
}

.search-box::before {
    content: '🔍';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
}

.btn-success {
    background: linear-gradient(135deg, var(--secondary), #059669);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning), #d97706);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Tabela */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead {
    background: var(--gray-lighter);
}

.table th {
    padding: 10px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.table td {
    padding: 10px 12px;
    border-top: 1px solid var(--gray-lighter);
    font-size: 13px;
    white-space: nowrap;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: rgba(99, 102, 241, 0.03);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

.badge-info {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-dark);
}

/* Botões de Ação da Tabela */
.action-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: center;
}

.btn-xs {
    padding: 5px 8px;
    font-size: 11px;
    border-radius: 6px;
    white-space: nowrap;
}

.btn-action-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
    border-radius: 8px;
}

/* Paginação da lista de clientes */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-lighter);
}

.pagination-info {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    min-width: 120px;
    text-align: center;
}

.btn-info {
    background: var(--primary);
    color: var(--white);
}

.btn-info:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* ========================================
   MODAL
   ======================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 750px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-lighter);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gray-lighter);
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--gray-light);
    transform: rotate(90deg);
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-lighter);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Formulários em Grid */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

select.form-control,
textarea.form-control {
    font-family: inherit;
}

textarea.form-control {
    resize: vertical;
    min-height: 70px;
}

/* Checkbox customizado */
.checkbox-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding: 10px;
    background: var(--gray-lighter);
    border-radius: var(--radius-sm);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

.checkbox-item label {
    margin: 0;
    cursor: pointer;
    font-weight: 500;
}

/* ========================================
   LOADING E NOTIFICAÇÕES
   ======================================== */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading.active {
    display: flex;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--gray-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    background: var(--white);
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    min-width: 300px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.active {
    display: flex;
}

.toast.success {
    border-left: 4px solid var(--secondary);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast-icon {
    font-size: 24px;
}

.toast-message {
    flex: 1;
    font-weight: 500;
}

/* ========================================
   RESPONSIVO
   ======================================== */
@media (max-width: 768px) {
    .login-box {
        padding: 32px 24px;
    }

    .container {
        padding: 16px 12px;
    }
    
    .navbar {
        padding: 12px 0;
    }

    .navbar-container {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 0 12px;
    }

    .navbar-brand h2 {
        font-size: 20px;
    }

    .navbar-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .navbar-meta {
        justify-content: space-between;
        width: 100%;
        padding: 10px 12px;
        background: var(--gray-lighter);
        border-radius: 10px;
    }

    .navbar-buttons {
        width: 100%;
    }

    .navbar-buttons .btn {
        flex: 1;
        min-height: 40px;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 16px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-title {
        font-size: 11px;
    }

    .stat-value {
        font-size: 22px;
    }

    .stat-card[data-filter="trial-expired"] {
        grid-column: 1 / -1;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .search-box {
        min-width: 100%;
    }

    .toolbar-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .toolbar-actions .btn {
        min-height: 42px;
        width: 100%;
    }

    .toolbar-actions .btn:last-child {
        grid-column: 1 / -1;
    }

    /* Esconde tabela e mostra cards no mobile */
    .clients-table-wrap {
        display: none;
    }

    .clients-mobile-list {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .client-mobile-card {
        background: var(--gray-lighter);
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 14px;
    }

    .client-mobile-top {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 12px;
    }

    .client-mobile-user {
        font-weight: 700;
        font-size: 16px;
        color: var(--dark);
        word-break: break-all;
    }

    .client-mobile-name {
        font-size: 13px;
        color: var(--gray);
        margin-top: 2px;
    }

    .client-mobile-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 12px;
    }

    .client-mobile-grid span {
        display: block;
        font-size: 11px;
        color: var(--gray);
        margin-bottom: 2px;
    }

    .client-mobile-grid strong {
        font-size: 13px;
        color: var(--dark);
        word-break: break-word;
    }

    .client-mobile-card .action-buttons {
        justify-content: flex-start;
        gap: 8px;
    }

    .client-mobile-card .btn-action-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .clients-mobile-empty {
        text-align: center;
        color: var(--gray);
        padding: 28px 12px;
        background: var(--gray-lighter);
        border-radius: 12px;
    }

    .pagination-bar {
        gap: 10px;
        flex-wrap: wrap;
    }

    .pagination-bar .btn {
        min-height: 40px;
        flex: 1;
    }
    
    .action-buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .modal {
        align-items: flex-end;
        padding: 0;
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
        margin: 0;
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        background: var(--white);
        gap: 8px;
    }

    .modal-footer .btn {
        flex: 1;
        min-height: 44px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }

    .bouquet-checkboxes,
    .checkbox-group {
        max-height: 220px;
    }
}

@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card[data-filter="trial-expired"] {
        grid-column: auto;
    }

    .toolbar-actions {
        grid-template-columns: 1fr;
    }

    .toolbar-actions .btn:last-child {
        grid-column: auto;
    }
}

/* ========================================
   UTILIDADES
   ======================================== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.d-none {
    display: none;
}

.text-muted {
    color: var(--gray);
}

.text-small {
    font-size: 12px;
}

.font-weight-bold {
    font-weight: 700;
}
