/**
 * SurveyHub - Responsive Design
 * 
 * Media queries e ajustes para diferentes tamanhos de tela.
 * Mobile-first approach.
 * 
 * US-003: Responsividade Mobile Completa
 * - Font-size base 16px (evita zoom no iOS)
 * - Botões mínimo 48x48px (WCAG 2.1 AA)
 * - Touch targets >= 44px
 * - Viewport otimizado para mobile
 */

/* ========================================
   Global Mobile Optimizations
   ======================================== */

/* Prevent zoom on input focus (iOS) */
body {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
}

/* All interactive elements: minimum 48x48px */
button, 
.btn, 
a.btn, 
input[type="submit"], 
input[type="button"],
input[type="reset"] {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 20px;
    font-size: 16px;
    line-height: 1.5;
}

/* Form inputs: prevent zoom on iOS */
input,
textarea,
select,
.form-control,
.form-select {
    font-size: 16px;
}

/* Links: adequate touch target (exceto botões) */
a:not(.btn):not(.btn-primary):not(.btn-secondary):not(.btn-outline-primary):not(.btn-outline-secondary):not(.btn-link):not(.dropdown-item):not(.nav-link) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

/* Remove tap highlight on touch devices */
* {
    -webkit-tap-highlight-color: transparent;
}

/* ========================================
   Extra Small devices (< 576px) - Mobile First
   ======================================== */
@media (max-width: 575.98px) {
    /* Buttons: Full width on mobile */
    button:not(.btn-icon),
    .btn:not(.btn-icon),
    input[type="submit"],
    input[type="button"] {
        width: 100%;
        margin-bottom: 12px;
    }
    
    /* Stack button groups */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group > .btn {
        width: 100%;
        margin: 4px 0;
    }
    
    /* Cards: reduce padding */
    .card,
    .survey-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    /* Typography: smaller on mobile */
    h1, .h1 { font-size: 1.75rem; }
    h2, .h2 { font-size: 1.5rem; }
    h3, .h3 { font-size: 1.25rem; }
    h4, .h4 { font-size: 1.125rem; }
    
    /* Navigation: hamburger menu */
    .navbar-collapse {
        max-height: 70vh;
        overflow-y: auto;
    }
    
    /* Survey questions: full width */
    .question-block,
    .question-card {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }
    
    /* Images: responsive */
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* Tables: scroll horizontally */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    /* Progress bar: larger on mobile */
    .progress {
        height: 8px;
    }
}

/* ========================================
   Small devices (landscape phones, 576px and up)
   ======================================== */
@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
}

/* ========================================
   Medium devices (tablets, 768px and up)
   ======================================== */
@media (max-width: 768px) {
    /* Typography */
    h1, .h1 {
        font-size: 2rem;
    }
    
    h2, .h2 {
        font-size: 1.75rem;
    }
    
    h3, .h3 {
        font-size: 1.5rem;
    }
    
    /* Navbar */
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    .nav-link {
        padding: 0.75rem 0;
    }
    
    /* Survey Cards */
    .survey-card {
        padding: 1rem;
    }
    
    .survey-header {
        flex-direction: column;
    }
    
    .survey-actions {
        width: 100%;
        margin-top: 1rem;
    }
    
    .survey-actions .btn {
        flex: 1;
    }
    
    /* Likert Scale - Stack vertically on mobile */
    .likert-scale {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .likert-option label {
        padding: 0.75rem 1rem;
    }
    
    /* Stats Cards - Full width on mobile */
    .stats-card {
        margin-bottom: 1rem;
    }
    
    /* Question Cards */
    .question-card {
        padding: 1.5rem 1rem;
    }
    
    /* Tables - Horizontal scroll */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Buttons - Full width on mobile */
    .btn-block-mobile {
        display: block;
        width: 100%;
    }
    
    /* Forms */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Modal - Full screen on mobile */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }
    
    .modal-content {
        height: 100%;
        border: 0;
        border-radius: 0;
    }
    
    /* Toast notifications */
    .toast-container {
        right: 0.5rem;
        left: 0.5rem;
        top: 0.5rem;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
    }
    
    /* Progress bar */
    .progress {
        height: 6px;
    }
    
    /* Empty state */
    .empty-state {
        padding: 2rem 1rem;
    }
    
    .empty-state-icon {
        font-size: 3rem;
    }
}

/* ========================================
   Large devices (desktops, 992px and up)
   ======================================== */
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
    
    /* Survey list - Two columns */
    .survey-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    /* Stats cards - Three columns */
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

/* ========================================
   Extra large devices (large desktops, 1200px and up)
   ======================================== */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
    
    /* Survey list - Three columns */
    .survey-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ========================================
   Extra extra large devices (1400px and up)
   ======================================== */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* ========================================
   Portrait orientation
   ======================================== */
@media (orientation: portrait) {
    /* Adjust spacing for portrait mode */
    .question-card {
        margin-bottom: 1rem;
    }
}

/* ========================================
   Landscape orientation
   ======================================== */
@media (orientation: landscape) and (max-height: 600px) {
    /* Reduce vertical padding in landscape on small devices */
    .navbar {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .question-card {
        padding: 1rem;
    }
}

/* ========================================
   Print styles
   ======================================== */
@media print {
    /* Hide non-printable elements */
    .navbar,
    .footer,
    .btn,
    .no-print,
    .survey-actions {
        display: none !important;
    }
    
    /* Optimize for printing */
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }
    
    .container {
        max-width: 100%;
    }
    
    .card,
    .survey-card,
    .question-card {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
    
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
    
    /* Show URLs for links */
    a[href]:after {
        content: " (" attr(href) ")";
    }
    
    /* Hide link URLs for buttons */
    .btn[href]:after {
        content: "";
    }
}

/* ========================================
   Dark mode support (future)
   ======================================== */
@media (prefers-color-scheme: dark) {
    /* Placeholder for future dark mode implementation */
    /* 
    :root {
        --bg-primary: #1a1a1a;
        --text-primary: #ffffff;
    }
    */
}

/* ========================================
   Reduced motion for accessibility
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .btn:hover {
        transform: none;
    }
    
    .card:hover {
        transform: none;
    }
    
    .survey-card:hover {
        transform: none;
    }
}

/* ========================================
   High contrast mode for accessibility
   ======================================== */
@media (prefers-contrast: high) {
    .btn {
        border-width: 2px;
    }
    
    .form-control,
    .form-select {
        border-width: 2px;
    }
    
    .card,
    .survey-card {
        border-width: 2px;
    }
}

/* ========================================
   Touch device optimizations
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
    }
    
    .nav-link {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover,
    .card:hover,
    .survey-card:hover {
        transform: none;
    }
    
    /* Larger form controls */
    .form-control,
    .form-select {
        min-height: 44px;
    }
    
    /* Radio buttons and checkboxes */
    input[type="radio"],
    input[type="checkbox"] {
        min-width: 24px;
        min-height: 24px;
    }
}

