:root {
    --bg-dark: #1a1d21;
    --bg-card: #212529;
    --bg-sidebar: #16191c;
    --text-primary: #ffffff;
    --text-muted: #8a8d91;
    --accent: #0d6efd;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #0dcaf0;
    --border-color: #2d3238;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #4dabf7; }

/* Layout */
.wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
    font-size: 1.3rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-logo {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo h2 {
    font-size: 1.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu, .menu { padding: 15px 0; }

.menu-header {
    padding: 10px 20px;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-muted);
    transition: all 0.3s;
}

.menu-item:hover, .menu-item.active {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
    border-left: 3px solid var(--accent);
}

.menu-item i { width: 24px; margin-right: 10px; }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: var(--bg-card);
    border-radius: 10px;
    margin-bottom: 20px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-credits {
    background: var(--accent-gradient);
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.card-body { padding: 20px; }

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
}

.stat-card.green::before { background: linear-gradient(135deg, #198754, #20c997); }
.stat-card.yellow::before { background: linear-gradient(135deg, #ffc107, #fd7e14); }
.stat-card.red::before { background: linear-gradient(135deg, #dc3545, #e91e63); }
.stat-card.blue::before { background: linear-gradient(135deg, #0dcaf0, #0d6efd); }

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 15px;
    background: rgba(255,255,255,0.1);
}

.stat-value { font-size: 2rem; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 0.85rem; }

/* Tables */
.table-container { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
}

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

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: rgba(255,255,255,0.05);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
}

tr:hover { background: rgba(255,255,255,0.02); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s;
    text-decoration: none;
    color: white;
}

.btn-primary { background: var(--accent-gradient); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: #000; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: #6c757d; color: white; }
.btn-info { background: var(--info); color: #000; }

.btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 8px; width: 35px; height: 35px; justify-content: center; }

/* Badges */
.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.badge-success { background: rgba(25, 135, 84, 0.2); color: #20c997; }
.badge-danger { background: rgba(220, 53, 69, 0.2); color: #f66; }
.badge-warning { background: rgba(255, 193, 7, 0.2); color: #ffc107; }
.badge-info { background: rgba(13, 202, 240, 0.2); color: #0dcaf0; }

/* Forms */
.form-group { margin-bottom: 15px; }
.form-label { display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 0.9rem; }

.form-control {
    width: 100%;
    padding: 12px 15px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px; /* Previne zoom no iOS */
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238a8d91' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

.input-group {
    display: flex;
    gap: 0;
}

.input-group .form-control { 
    border-radius: 8px 0 0 8px; 
    flex: 1;
    min-width: 0;
}
.input-group .btn { border-radius: 0 8px 8px 0; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--bg-card);
    border-radius: 15px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body { padding: 20px; }
.modal-footer { 
    padding: 15px 20px; 
    border-top: 1px solid var(--border-color); 
    display: flex; 
    gap: 10px; 
    justify-content: flex-end;
    flex-wrap: wrap;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.tab-btn.active,
.tab-btn:hover {
    background: var(--accent-gradient);
    color: #fff;
    border-color: transparent;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: rgba(25, 135, 84, 0.2); border: 1px solid var(--success); }
.alert-danger { background: rgba(220, 53, 69, 0.2); border: 1px solid var(--danger); }
.alert-warning { background: rgba(255, 193, 7, 0.2); border: 1px solid var(--warning); }

/* Actions */
.actions { 
    display: flex; 
    gap: 5px;
    flex-wrap: wrap;
}

/* Search/Filter */
.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filters .form-control { 
    width: auto; 
    min-width: 150px;
    flex: 1;
}

.filters .btn {
    white-space: nowrap;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

/* =====================================================
   RESPONSIVIDADE - MOBILE
   ===================================================== */

/* Menu Hamburger */
.menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--accent-gradient);
    border: none;
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 10px;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.active { display: block; }

/* Tablet - até 992px */
@media (max-width: 992px) {
    .menu-toggle { 
        display: flex; 
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }
    
    .sidebar.active { 
        transform: translateX(0); 
    }
    
    .main-content { 
        margin-left: 0; 
        padding: 20px;
        padding-top: 70px;
    }
}

/* Mobile - até 768px */
@media (max-width: 768px) {
    .main-content { 
        padding: 15px;
        padding-top: 70px;
    }
    
    /* Header */
    .header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 15px;
    }
    
    .header-user {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    /* Page header com botão */
    .page-header,
    div[style*="display: flex"][style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
    }
    
    .page-header .btn,
    div[style*="display: flex"][style*="justify-content: space-between"] .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Stats Grid */
    .stats-grid { 
        grid-template-columns: 1fr 1fr !important; 
        gap: 10px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-value { font-size: 1.5rem; }
    .stat-label { font-size: 0.75rem; }
    .stat-icon { width: 40px; height: 40px; font-size: 1.2rem; }
    
    /* Filtros */
    .filters {
        flex-direction: column;
        gap: 10px;
    }
    
    .filters .form-control,
    .filters select,
    .filters input { 
        width: 100% !important; 
        min-width: 100% !important;
    }
    
    .filters .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Tabelas */
    .table-container {
        margin: 0 -15px;
        padding: 0 15px;
    }
    
    table {
        font-size: 0.8rem;
        min-width: 500px;
    }
    
    th, td {
        padding: 10px 8px;
    }
    
    /* Esconder colunas menos importantes */
    table th:first-child,
    table td:first-child {
        display: none; /* ID */
    }
    
    /* Ações */
    .actions {
        gap: 3px;
    }
    
    .actions .btn,
    .actions .btn-sm {
        padding: 5px 8px;
        font-size: 0.7rem;
    }
    
    .btn-icon {
        width: 30px;
        height: 30px;
        padding: 5px;
    }
    
    /* Cards */
    .card {
        border-radius: 8px;
    }
    
    .card-header {
        padding: 12px 15px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    /* Botões */
    .btn {
        padding: 10px 15px;
        font-size: 0.85rem;
    }
    
    .btn-sm {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    /* Modal */
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-footer {
        padding: 15px;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: 100px;
    }
    
    /* Grids de 2 colunas para 1 */
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns: repeat(2"] {
        grid-template-columns: 1fr !important;
    }
    
    /* Títulos */
    h1 { font-size: 1.3rem; }
    h2 { font-size: 1.1rem; }
    h3 { font-size: 1rem; }
    
    /* Tabs */
    .tabs {
        gap: 5px;
    }
    
    .tab-btn {
        flex: 1;
        min-width: 70px;
        padding: 8px 10px;
        font-size: 0.75rem;
        text-align: center;
    }
    
    /* Input groups */
    .input-group {
        flex-wrap: nowrap;
    }
    
    .input-group .form-control {
        min-width: 0;
    }
    
    .input-group .btn {
        padding: 10px 12px;
        white-space: nowrap;
    }
    
    /* Link types (modal gerar link) */
    .link-types {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    .link-type-btn {
        padding: 10px 8px !important;
    }
    
    .link-type-btn i {
        font-size: 16px !important;
    }
    
    .link-type-btn span {
        font-size: 10px !important;
    }
    
    /* Badges */
    .badge {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
}

/* Mobile pequeno - até 480px */
@media (max-width: 480px) {
    .main-content {
        padding: 10px;
        padding-top: 65px;
    }
    
    /* Stats 1 coluna */
    .stats-grid { 
        grid-template-columns: 1fr !important; 
    }
    
    .stat-value { font-size: 1.3rem; }
    
    /* Header */
    .header-credits {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    /* Esconder mais colunas da tabela */
    table th:nth-child(3),
    table td:nth-child(3) {
        display: none;
    }
    
    table {
        font-size: 0.75rem;
    }
    
    th, td {
        padding: 8px 6px;
    }
    
    /* Ações em scroll horizontal */
    .actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 5px;
    }
    
    .actions .btn {
        flex-shrink: 0;
    }
    
    /* Link types 2 colunas */
    .link-types {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Form labels */
    .form-label {
        font-size: 0.8rem;
    }
    
    /* Page title */
    h2 i {
        display: none;
    }
}

/* =====================================================
   COMPONENTES ESPECÍFICOS
   ===================================================== */

/* Toggle switch */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #38ef7d;
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .toggle-slider {
    background-color: #f5576c;
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Países grid */
.paises-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

@media (max-width: 768px) {
    .paises-grid {
        grid-template-columns: 1fr !important;
    }
}

/* API Box */
.api-box {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.api-url {
    background: var(--bg-dark);
    padding: 12px 15px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.8rem;
    word-break: break-all;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

@media (max-width: 768px) {
    .api-url {
        flex-direction: column;
        align-items: stretch;
    }
    
    .api-url code {
        margin-bottom: 10px;
    }
}

/* Stat boxes para páginas específicas */
.stat-box {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.stat-box .value {
    font-size: 32px;
    font-weight: 700;
}

.stat-box .label {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 5px;
}

.stat-box.danger .value { color: #f5576c; }
.stat-box.success .value { color: #38ef7d; }
.stat-box.info .value { color: #4facfe; }

@media (max-width: 768px) {
    .stat-box {
        padding: 15px;
    }
    
    .stat-box .value {
        font-size: 24px;
    }
}

/* Scrollbar customizada */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Animações */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card, .stat-card {
    animation: fadeIn 0.3s ease;
}

/* Fix para iOS */
@supports (-webkit-touch-callout: none) {
    .modal {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
