/* ========================================
   MQTT Hub - Global Styles
   Estilos globais responsivos
   ======================================== */

/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ========================================
   SIDEBAR - Mobile First
   ======================================== */

.sidebar {
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: fixed;
    left: 0;
    top: 0;
    width: 16rem; /* 256px */
    background: white;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 50;
    border-right: 1px solid #f3f4f6;
}

/* Mobile: Sidebar oculta por padrão */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

/* Desktop: Sidebar sempre visível */
@media (min-width: 769px) {
    .sidebar {
        transform: translateX(0);
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.sidebar-item {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    color: #374151;
    text-decoration: none;
    /* Aumenta área de toque para mobile */
    min-height: 44px;
}

.sidebar-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: #2c7be5;
    transition: height 0.2s ease;
}

.sidebar-item:hover::before,
.sidebar-item:active::before {
    height: 70%;
}

.sidebar-item:hover,
.sidebar-item:active {
    background: rgba(44, 123, 229, 0.08);
    padding-left: 1.125rem;
}

.sidebar-item.active {
    background: linear-gradient(90deg, rgba(44, 123, 229, 0.15) 0%, rgba(44, 123, 229, 0.05) 100%);
    color: #2c7be5;
    font-weight: 600;
}

.sidebar-item.active::before {
    height: 70%;
}

/* ========================================
   CARDS - Responsivos
   ======================================== */

.card-hover {
    transition: all 0.3s ease;
}

/* Desabilita efeito hover em touch devices */
@media (hover: hover) {
    .card-hover:hover {
        transform: translateY(-4px);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    }
}

/* ========================================
   TABELAS RESPONSIVAS
   ======================================== */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    min-width: 100%;
}

/* Mobile: Esconde tabela, mostra cards */
@media (max-width: 768px) {
    .table-desktop {
        display: none;
    }

    .cards-mobile {
        display: block;
    }
}

/* Desktop: Mostra tabela, esconde cards */
@media (min-width: 769px) {
    .table-desktop {
        display: table;
    }

    .cards-mobile {
        display: none;
    }
}

/* ========================================
   FORMULÁRIOS RESPONSIVOS
   ======================================== */

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s;
    /* Área de toque adequada */
    min-height: 44px;
}

.form-input:focus {
    outline: none;
    border-color: #2c7be5;
    ring: 2px;
    ring-color: rgba(44, 123, 229, 0.2);
}

@media (min-width: 768px) {
    .form-input {
        font-size: 1rem;
        padding: 0.875rem 1.25rem;
    }
}

/* ========================================
   BOTÕES RESPONSIVOS
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    /* Área de toque mínima (WCAG) */
    min-height: 44px;
    min-width: 44px;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

@media (min-width: 768px) {
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

.btn-primary {
    background: linear-gradient(135deg, #2c7be5 0%, #1e6ac8 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1e6ac8 0%, #1659ab 100%);
}

/* ========================================
   GRID RESPONSIVO
   ======================================== */

.grid-responsive {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .grid-responsive {
        gap: 1.5rem;
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .grid-responsive {
        gap: 1.5rem;
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) {
    .grid-responsive {
        gap: 2rem;
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ========================================
   TIPOGRAFIA RESPONSIVA
   ======================================== */

.text-responsive-xs {
    font-size: 0.75rem;
}

.text-responsive-sm {
    font-size: 0.875rem;
}

.text-responsive-base {
    font-size: 0.875rem;
}

.text-responsive-lg {
    font-size: 1rem;
}

.text-responsive-xl {
    font-size: 1.125rem;
}

.text-responsive-2xl {
    font-size: 1.25rem;
}

.text-responsive-3xl {
    font-size: 1.5rem;
}

@media (min-width: 768px) {
    .text-responsive-base {
        font-size: 1rem;
    }

    .text-responsive-lg {
        font-size: 1.125rem;
    }

    .text-responsive-xl {
        font-size: 1.25rem;
    }

    .text-responsive-2xl {
        font-size: 1.5rem;
    }

    .text-responsive-3xl {
        font-size: 1.875rem;
    }
}

@media (min-width: 1024px) {
    .text-responsive-3xl {
        font-size: 2.25rem;
    }
}

/* ========================================
   ESPAÇAMENTOS RESPONSIVOS
   ======================================== */

.container-responsive {
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 640px) {
    .container-responsive {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .container-responsive {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* ========================================
   ANIMAÇÕES
   ======================================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(44, 123, 229, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(44, 123, 229, 0.6);
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.5s ease-out forwards;
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.4s ease-out forwards;
}

.animate-pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* Delays para animações em cascata */
.stagger-1 {
    animation-delay: 0.05s;
    opacity: 0;
}

.stagger-2 {
    animation-delay: 0.1s;
    opacity: 0;
}

.stagger-3 {
    animation-delay: 0.15s;
    opacity: 0;
}

.stagger-4 {
    animation-delay: 0.2s;
    opacity: 0;
}

/* ========================================
   MODAIS RESPONSIVOS
   ======================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 0;
    border-radius: 1rem;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s;
    max-height: 90vh;
    overflow-y: auto;
}

@media (min-width: 768px) {
    .modal-content {
        width: 80%;
    }
}

/* ========================================
   INPUTS E FORMULÁRIOS ESPECIAIS
   ======================================== */

.profile-input:read-only {
    cursor: default;
    background-color: #f9fafb;
}

.verification-code-input {
    font-size: 1.25rem;
    letter-spacing: 0.5rem;
    text-align: center;
    font-weight: 600;
}

@media (min-width: 768px) {
    .verification-code-input {
        font-size: 1.5rem;
        letter-spacing: 0.5rem;
    }
}

/* ========================================
   SCROLLBAR CUSTOMIZADA
   ======================================== */

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #2c7be5;
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #1e6ac8;
}

/* ========================================
   STATUS BADGES
   ======================================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

@media (min-width: 768px) {
    .status-badge {
        padding: 0.375rem 1rem;
        font-size: 0.875rem;
    }
}

/* ========================================
   UTILIDADES RESPONSIVAS
   ======================================== */

/* Ocultar em mobile */
.hide-mobile {
    display: none;
}

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

/* Mostrar apenas em mobile */
.show-mobile {
    display: block;
}

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

/* Texto truncado com ellipsis */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

/* Stats Cards */
.stat-card {
    transition: all 0.3s ease;
    cursor: pointer;
}

@media (hover: hover) {
    .stat-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    }
}

/* Summary Sidebar (sticky) */
@media (min-width: 1024px) {
    .summary-sidebar {
        position: sticky;
        top: 5rem;
        max-height: calc(100vh - 6rem);
        overflow-y: auto;
    }
}

/* Table Rows */
.table-row {
    transition: all 0.2s ease;
    cursor: pointer;
}

.table-row:hover {
    background: #f8fafc;
}

.table-row.expanded {
    background: #f1f5f9;
}

.row-details {
    display: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.row-details.show {
    display: table-row;
    max-height: 500px;
}

.expand-icon {
    transition: transform 0.3s ease;
}

.expand-icon.rotated {
    transform: rotate(180deg);
}

/* Section Content Toggle */
.status-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.status-section-content.show {
    max-height: 5000px;
}

/* ========================================
   ACESSIBILIDADE
   ======================================== */

/* Foco visível para teclado */
*:focus-visible {
    outline: 2px solid #2c7be5;
    outline-offset: 2px;
}

/* Remove outline para mouse */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Reduz movimento para quem prefere */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   DARK MODE (preparado para futuro)
   ======================================== */

@media (prefers-color-scheme: dark) {
    /* Estilos dark mode podem ser adicionados aqui */
}

/* ========================================
   PRELOADER
   ======================================== */

#pagePreloader {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #2c7be5 0%, #1e6ac8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#pagePreloader.hidden {
    opacity: 0;
    visibility: hidden;
}

.preloader-content {
    text-align: center;
    color: white;
}

.preloader-logo {
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: preloaderPulse 2s ease-in-out infinite;
}

.preloader-logo i {
    font-size: 2.5rem;
    color: #2c7be5;
}

@keyframes preloaderPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    }
}

.preloader-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 1.5rem;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: preloaderSpin 1s linear infinite;
}

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

.preloader-text {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    animation: fadeInOut 2s ease-in-out infinite;
}

.preloader-subtext {
    font-size: 0.875rem;
    opacity: 0.9;
}

@keyframes fadeInOut {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Preloader dots animation */
.preloader-dots::after {
    content: '';
    animation: preloaderDots 1.5s steps(4, end) infinite;
}

@keyframes preloaderDots {
    0%, 20% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80%, 100% {
        content: '...';
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .sidebar,
    .sidebar-overlay,
    .no-print,
    #pagePreloader {
        display: none !important;
    }

    body {
        margin: 0;
        padding: 0;
    }

    .md\:ml-64 {
        margin-left: 0 !important;
    }
}
