/* ============================================
   MOBILE RESPONSIVE STYLES
   Divulga Kaloferta - v1.0
   ============================================ */

/* ============================================
   BASE MOBILE FIXES
   ============================================ */

/* Prevent horizontal scroll on all devices */
html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Fix for iOS zoom on input focus */
input, select, textarea {
    font-size: 16px !important;
}

/* ============================================
   TABLET STYLES (max-width: 1024px)
   ============================================ */

@media (max-width: 1024px) {
    /* Dashboard container - reduce sidebar */
    .dashboard-container {
        grid-template-columns: 200px 1fr;
    }
    
    .sidebar-brand {
        font-size: 1.2rem;
    }
    
    /* Tables scroll horizontally */
    .data-table {
        overflow-x: auto;
    }
    
    table {
        min-width: 600px;
    }
}

/* ============================================
   MOBILE STYLES (max-width: 768px)
   ============================================ */

@media (max-width: 768px) {
    /* Dashboard - Stack sidebar and content */
    .dashboard-container {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
    }
    
    /* Sidebar becomes horizontal nav */
    .sidebar {
        position: relative !important;
        height: auto !important;
        width: 100% !important;
        padding: 1rem !important;
        overflow-x: auto;
        min-height: auto !important;
        max-height: none !important;
    }
    
    .sidebar-brand {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
        text-align: left;
    }
    
    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .sidebar-nav-item {
        margin-bottom: 0;
    }
    
    .sidebar-nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    
    /* Main content full width */
    .main-content {
        padding: 1rem !important;
        width: 100%;
        min-width: 0;
    }
    
    /* Headers */
    .dashboard-header,
    .admin-header {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .dashboard-header h1,
    .admin-header h1 {
        font-size: 1.3rem;
    }
    
    .dashboard-header p,
    .admin-header p {
        font-size: 0.85rem;
    }
    
    /* Tab navigation - scrollable */
    .tab-nav {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        flex-wrap: nowrap;
    }
    
    .tab-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    /* Stats grid - 2 columns on mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    .stat-card {
        padding: 0.75rem !important;
    }
    
    .stat-value {
        font-size: 1.3rem !important;
    }
    
    .stat-label {
        font-size: 0.75rem !important;
    }
    
    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
    
    .stat-change {
        font-size: 0.7rem;
    }
    
    /* Charts - full width */
    .grid-2 {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .chart-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .chart-title {
        font-size: 1rem !important;
    }
    
    .chart-subtitle {
        font-size: 0.8rem !important;
    }
    
    .chart-controls,
    .chart-header > div:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
    }
    
    .chart-type-btn {
        padding: 4px 8px;
        font-size: 14px;
    }
    
    .filter-select {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    /* Canvas height */
    canvas {
        max-height: 250px !important;
    }
    
    /* Tables */
    .data-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 0.8rem;
    }
    
    th, td {
        padding: 0.5rem 0.4rem !important;
        white-space: nowrap;
    }
    
    /* Grid overrides */
    .grid-3 {
        grid-template-columns: 1fr !important;
    }
    
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Cards */
    .card {
        padding: 1rem;
    }
    
    .card-title {
        font-size: 0.95rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .btn-sm {
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Action buttons */
    .action-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }
    
    /* Search input */
    .search-input {
        width: 100% !important;
        font-size: 0.9rem;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .pagination button {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    /* Error logs */
    .error-log-item {
        padding: 0.75rem;
        font-size: 0.8rem;
    }
    
    .error-log-time {
        font-size: 0.7rem;
    }
    
    .error-log-file {
        font-size: 0.65rem;
    }
    
    #errorLogsContainer {
        max-height: 300px;
    }
    
    /* Badges */
    .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

/* ============================================
   AUTH PAGES (Login, Register, etc)
   ============================================ */

@media (max-width: 768px) {
    .auth-container {
        padding: 1rem;
        align-items: flex-start;
        padding-top: 2rem;
    }
    
    .auth-card {
        padding: 1.25rem;
        max-width: 100%;
        border-radius: 12px;
    }
    
    .auth-header h1 {
        font-size: 1.5rem;
    }
    
    .auth-header p {
        font-size: 0.9rem;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
    }
    
    .form-group input {
        padding: 0.75rem;
    }
    
    .btn-auth {
        padding: 0.85rem;
        font-size: 1rem;
    }
    
    .auth-footer {
        font-size: 0.9rem;
    }
}

/* ============================================
   INDEX/HOME PAGE
   ============================================ */

@media (max-width: 768px) {
    /* Navbar */
    .navbar {
        padding: 0.5rem 0;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .nav-desktop {
        display: none !important;
    }
    
    #navAuthButtons {
        display: flex;
        gap: 0.5rem;
    }
    
    #navAuthButtons .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    /* Hero */
    .hero {
        padding: 2rem 0;
    }
    
    .hero-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .hero-avatar {
        width: 80px;
        height: 80px;
    }
    
    .hero h1 {
        font-size: 1.5rem !important;
    }
    
    .hero p {
        font-size: 0.9rem;
    }
    
    .hero-btn {
        font-size: 0.9rem;
        padding: 0.75rem 1.25rem;
    }
    
    .hero-actions {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
        padding: 0 1rem;
    }
    
    .hero-actions .btn {
        width: 100%;
    }
    
    /* Features */
    .feature-card {
        padding: 1.25rem;
    }
    
    .feature-icon {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    /* Platform cards */
    .platform-card {
        padding: 1rem;
    }
    
    .platform-icon {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }
    
    /* Footer */
    .footer {
        padding: 2rem 0 1rem;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }
    
    .footer-section {
        width: 100%;
    }
    
    /* Floating banner */
    .floating-banner {
        left: 0.5rem;
        right: 0.5rem;
        bottom: 0.5rem;
        padding: 1rem;
    }
    
    .floating-banner h3 {
        font-size: 1rem;
    }
    
    .floating-banner p {
        font-size: 0.85rem;
    }
    
    .floating-banner-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
}

/* ============================================
   PLANOS PAGE
   ============================================ */

@media (max-width: 768px) {
    .plans-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .plan-card {
        padding: 1.25rem;
    }
    
    .plan-price {
        font-size: 2rem;
    }
    
    .plan-name {
        font-size: 1.2rem;
    }
    
    .plan-features li {
        font-size: 0.9rem;
    }
    
    .back-btn {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }
}

/* ============================================
   API DOCS PAGE
   ============================================ */

@media (max-width: 768px) {
    .api-section {
        padding: 1rem;
    }
    
    .endpoint-card {
        padding: 1rem;
    }
    
    .method-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
    
    .endpoint-url {
        font-size: 0.8rem;
        word-break: break-all;
    }
    
    pre, code {
        font-size: 0.75rem;
        overflow-x: auto;
    }
}

/* ============================================
   TICKETS PAGE
   ============================================ */

@media (max-width: 768px) {
    .ticket-list {
        gap: 0.75rem;
    }
    
    .ticket-item {
        padding: 1rem;
    }
    
    .ticket-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .ticket-id {
        font-size: 0.85rem;
    }
    
    .ticket-status {
        font-size: 0.7rem;
    }
    
    .ticket-preview {
        font-size: 0.85rem;
    }
    
    .chat-container {
        height: calc(100vh - 200px);
    }
    
    .chat-messages {
        padding: 1rem;
    }
    
    .chat-input-area {
        padding: 0.75rem;
    }
    
    .chat-input {
        font-size: 0.9rem;
    }
}

/* ============================================
   TERMS PAGE
   ============================================ */

@media (max-width: 768px) {
    .terms-container {
        padding: 1rem;
    }
    
    .terms-content {
        padding: 1.25rem;
    }
    
    .terms-content h1 {
        font-size: 1.5rem;
    }
    
    .terms-content h2 {
        font-size: 1.2rem;
    }
    
    .terms-content h3 {
        font-size: 1rem;
    }
    
    .terms-content p,
    .terms-content li {
        font-size: 0.9rem;
    }
}

/* ============================================
   SMALL PHONES (max-width: 480px)
   ============================================ */

@media (max-width: 480px) {
    /* Stats - single column */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Even smaller fonts */
    .dashboard-header h1,
    .admin-header h1 {
        font-size: 1.1rem;
    }
    
    .chart-title {
        font-size: 0.9rem !important;
    }
    
    .sidebar-nav-link {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    table {
        font-size: 0.75rem;
    }
    
    th, td {
        padding: 0.4rem 0.3rem !important;
    }
    
    .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    canvas {
        max-height: 200px !important;
    }
    
    /* Hero */
    .hero h1 {
        font-size: 1.3rem !important;
    }
    
    .hero-avatar {
        width: 60px;
        height: 60px;
    }
}

/* ============================================
   CHANGELOG OVERLAY MOBILE
   ============================================ */

@media (max-width: 768px) {
    .changelog-overlay {
        padding: 1rem;
        padding-top: 60px;
    }
    
    .changelog-panel {
        max-height: 90vh;
        border-radius: 12px;
    }
    
    .changelog-header {
        padding: 1rem;
    }
    
    .changelog-header h2 {
        font-size: 1.1rem;
    }
    
    .changelog-body {
        padding: 1rem;
        max-height: 70vh;
    }
    
    .changelog-version {
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }
    
    .changelog-version-title {
        font-size: 1rem;
    }
    
    .changelog-changes li {
        font-size: 0.85rem;
    }
}

/* ============================================
   CHAT SUPPORT WIDGET MOBILE
   ============================================ */

@media (max-width: 768px) {
    .chat-widget-btn {
        width: 50px;
        height: 50px;
        bottom: 15px;
        right: 15px;
        font-size: 1.3rem;
    }
    
    .chat-window {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 70vh;
        max-height: 70vh;
        border-radius: 20px 20px 0 0;
    }
    
    .chat-header h3 {
        font-size: 1rem;
    }
    
    .chat-body {
        height: calc(70vh - 130px);
    }
}

/* ============================================
   UTILITY CLASSES FOR MOBILE
   ============================================ */

/* Hide on mobile */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Mobile only visible */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
}

/* Scrollable container */
.scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Full width on mobile */
@media (max-width: 768px) {
    .mobile-full-width {
        width: 100% !important;
    }
}
