/**
 * Sistema de Licenças IPTV - 100% Mobile First
 */

/* ==================== VARIABLES ==================== */
:root {
    --primary: #FF4500;
    --primary-dark: #cc3700;
    --secondary: #1a1a2e;
    --accent: #4a0080;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1f2937;
    --light: #f3f4f6;
    --border: #e5e7eb;
    --text: #374151;
    --text-muted: #6b7280;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --radius: 12px;
    --radius-lg: 16px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--accent) 100%);
    min-height: 100vh;
    color: var(--text);
    line-height: 1.5;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

/* ==================== CONTAINER ==================== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

@media (min-width: 768px) {
    .container {
        padding: 0 24px;
    }
}

/* ==================== TYPOGRAPHY ==================== */
h1 { font-size: clamp(1.5rem, 5vw, 2.5rem); }
h2 { font-size: clamp(1.25rem, 4vw, 2rem); }
h3 { font-size: clamp(1.1rem, 3vw, 1.5rem); }
h4 { font-size: clamp(1rem, 2.5vw, 1.25rem); }

.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.text-white { color: white; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* ==================== NAVBAR MOBILE FIRST ==================== */
.navbar {
    background: var(--secondary) !important;
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.25rem !important;
    color: white !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand i {
    color: var(--primary);
}

/* Desktop nav links */
.nav-links {
    display: none;
}

@media (min-width: 768px) {
    .nav-links {
        display: flex;
        gap: 8px;
    }
    
    .nav-links a {
        color: rgba(255, 255, 255, 0.8);
        text-decoration: none;
        padding: 8px 16px;
        border-radius: 8px;
        font-size: 0.9rem;
        transition: all 0.3s;
    }
    
    .nav-links a:hover {
        background: rgba(255, 255, 255, 0.1);
        color: white;
    }
}

/* Mobile bottom navigation */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--secondary);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 calc(8px + var(--safe-bottom));
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 0.75rem;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s;
}

.mobile-nav a i {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

.mobile-nav a.active,
.mobile-nav a:hover {
    color: var(--primary);
}

@media (min-width: 768px) {
    .mobile-nav {
        display: none;
    }
}

/* Body padding for mobile nav */
@media (max-width: 767px) {
    body {
        padding-bottom: calc(70px + var(--safe-bottom));
    }
}

/* ==================== BUTTONS - TOUCH FRIENDLY ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    min-height: 48px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
    touch-action: manipulation;
}

.btn-sm {
    padding: 8px 16px;
    min-height: 40px;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 16px 32px;
    min-height: 56px;
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:active {
    background: var(--primary-dark);
    transform: scale(0.98);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline-light {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
}

/* ==================== FORMS - MOBILE OPTIMIZED ==================== */
.form-group, .mb-3 {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--dark);
    font-size: 0.9rem;
}

.form-control, input, select, textarea {
    width: 100%;
    padding: 14px 16px;
    min-height: 48px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px; /* Previne zoom no iOS */
    transition: border-color 0.2s;
    background: white;
}

.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 69, 0, 0.1);
}

input::placeholder {
    color: #9ca3af;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.form-text, small {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

.text-danger { color: var(--danger); }

/* ==================== CARDS ==================== */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

.card-header {
    background: var(--secondary);
    color: white;
    padding: 16px 20px;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 20px;
}

@media (min-width: 768px) {
    .card-body {
        padding: 24px;
    }
}

/* ==================== GRID SYSTEM ==================== */
.grid {
    display: grid;
    gap: 16px;
}

.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr; }

@media (min-width: 480px) {
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ==================== STATS CARDS ==================== */
.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card h3 {
    font-size: 1.75rem;
    margin-bottom: 4px;
}

.stat-card p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.stat-card.primary h3 { color: var(--primary); }
.stat-card.green h3 { color: var(--success); }
.stat-card.purple h3 { color: var(--accent); }
.stat-card.dark h3 { color: var(--dark); }

/* ==================== TABLES - RESPONSIVE ==================== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

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

.table th {
    background: var(--light);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    font-size: 0.9rem;
}

/* Mobile card view instead of table */
@media (max-width: 767px) {
    .table-mobile {
        min-width: auto;
    }
    
    .table-mobile thead {
        display: none;
    }
    
    .table-mobile tbody tr {
        display: block;
        background: white;
        border-radius: var(--radius);
        margin-bottom: 12px;
        padding: 16px;
        box-shadow: var(--shadow);
    }
    
    .table-mobile tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid var(--light);
    }
    
    .table-mobile tbody td:last-child {
        border-bottom: none;
    }
    
    .table-mobile tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.8rem;
    }
}

/* ==================== BADGES ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-processing { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: var(--light); color: var(--text-muted); }

/* ==================== APP CARDS ==================== */
.app-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    cursor: pointer;
    border: 3px solid transparent;
    touch-action: manipulation;
}

.app-card:active {
    transform: scale(0.98);
}

.app-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 69, 0, 0.2);
}

.app-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.app-price {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--success);
}

/* ==================== LOGIN / AUTH ==================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.login-box {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    color: var(--dark);
    margin-bottom: 8px;
}

.login-box p {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 24px;
}

@media (min-width: 768px) {
    .login-box {
        padding: 40px;
    }
}

/* ==================== MODAL ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 24px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

@media (min-width: 768px) {
    .modal-overlay {
        align-items: center;
    }
    
    .modal-content {
        border-radius: var(--radius-lg);
        transform: translateY(20px);
    }
    
    .modal-overlay.active .modal-content {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================== QR CODE ==================== */
.qr-container {
    text-align: center;
    padding: 20px;
}

.qr-container img {
    max-width: 280px;
    width: 100%;
    border-radius: var(--radius);
    margin: 16px 0;
}

.pix-info {
    background: var(--light);
    border-radius: var(--radius);
    padding: 16px;
    margin: 16px 0;
}

.pix-key {
    font-family: monospace;
    font-size: 1rem;
    background: white;
    padding: 12px;
    border-radius: 8px;
    word-break: break-all;
    margin-top: 8px;
}

/* ==================== ALERTS ==================== */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--info);
}

/* ==================== SIDEBAR - ADMIN/PANEL ==================== */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    background: var(--secondary);
    padding: 20px 0;
    transform: translateX(-100%);
    transition: transform 0.3s;
    z-index: 1001;
    overflow-y: auto;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        display: none;
    }
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    color: white;
    font-size: 1.25rem;
    font-weight: bold;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand i {
    color: var(--primary);
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 16px 0;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.sidebar-menu li a:active,
.sidebar-menu li a.active {
    background: rgba(255, 69, 0, 0.1);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.main-content {
    flex: 1;
    padding: 20px;
    margin-left: 0;
}

@media (min-width: 1024px) {
    .main-content {
        margin-left: 260px;
        padding: 30px;
    }
}

/* Menu toggle button */
.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
}

@media (min-width: 1024px) {
    .menu-toggle {
        display: none;
    }
}

/* ==================== TABS ==================== */
.tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    margin-bottom: 20px;
}

.tab {
    flex-shrink: 0;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.tab.active {
    background: var(--primary);
    color: white;
}

/* ==================== LOADING ==================== */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

/* ==================== UTILITY CLASSES ==================== */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.w-full { width: 100%; }

/* ==================== DARK MODE SUPPORT ==================== */
@media (prefers-color-scheme: dark) {
    /* Can add dark mode styles here if needed */
}

/* ==================== PRINT STYLES ==================== */
@media print {
    .sidebar, .mobile-nav, .navbar {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .main-content {
        margin-left: 0;
    }
}
