/* ========================================
   GLOBAL NAVBAR - CUIDAR DE SI
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

/* Sistema de Cores e Tipografia */
:root {
    /* Tipografia global (texto uniforme em toda a app) */
    --font-primary: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

    /* Cores Principais */
    --primary-color: #4a90e2;
    --primary-hover: #357abd;
    --secondary-color: #f8f9fa;
    
    /* Cores de Texto */
    --text-color: #333;
    --text-muted: #666;
    --text-light: #fff;
    
    /* Cores de Fundo */
    --bg-white: #fff;
    --bg-light: #f8f9fa;
    
    /* Cores de Bordas */
    --border-color: #e2e8f0;
    --border-light: #ddd;
    
    /* Cores de Status */
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    
    /* Espaçamentos e Bordas */
    --border-radius: 8px;
    --border-radius-lg: 12px;
    
    /* Transições */
    --transition: all 0.3s ease;
    
    /* Altura da Navbar */
    --navbar-height: 56px;
    
    /* Sombras */
    --shadow: 0 2px 4px rgba(0,0,0,0.1);

    /* Brand background (Cloudinary) */
    --brand-bg-url: url('https://res.cloudinary.com/dang30ntq/image/upload/v1780310284/FundoInicio_h0uq2b.png');

    /* Glass transparent (alinhado ao login de inicio) */
    --glass-bg: rgba(255, 255, 255, 0.2);
    --glass-border: rgba(255, 255, 255, 0.35);
    --glass-blur: 16px;
    --glass-card-bg: rgba(255, 255, 255, 0.25);
    --glass-card-header-bg: rgba(248, 249, 250, 0.5);
    /* Header of each post/turno card (same light style everywhere) */
    --glass-item-card-header-bg: rgba(255, 255, 255, 0.55);
}

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

/* Fundo Global do Projeto */
body {
    background: linear-gradient(rgba(245,245,245,0.3), rgba(245,245,245,0.3)),
                var(--brand-bg-url) no-repeat center center fixed;
    background-size: cover;
    color: var(--text-color);
    font-family: var(--font-primary);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Esconder blocos animados em desktop */
.bg-shapes-mobile {
    display: none;
}

/* ========================================
   ANIMACAO FUNDO - Apenas Mobile
   Blocos flutuantes (de cadastro-estilo) para tornar a app mais amigavel
   ======================================== */
@media (max-width: 768px) {
    .bg-shapes-mobile {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: -1;
        overflow: hidden;
        pointer-events: none;
    }
    
    .bg-shapes-mobile .shape {
        position: absolute;
        background: rgba(255, 255, 255, 0.08);
        animation: float-shapes 6s ease-in-out infinite;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
    }
    
    .bg-shapes-mobile .shape:nth-child(1) {
        width: 80px; height: 55px; border-radius: 12px;
        top: 15%; left: 8%; animation-delay: 0s;
        --start-rotation: 15deg; transform: rotate(15deg);
    }
    .bg-shapes-mobile .shape:nth-child(2) {
        width: 60px; height: 95px; border-radius: 10px;
        top: 55%; right: 10%; left: auto; animation-delay: 2s;
        --start-rotation: -20deg; transform: rotate(-20deg);
    }
    .bg-shapes-mobile .shape:nth-child(3) {
        width: 70px; height: 45px; border-radius: 8px;
        bottom: 25%; left: 15%; animation-delay: 4s;
        --start-rotation: 25deg; transform: rotate(25deg);
    }
    .bg-shapes-mobile .shape:nth-child(4) {
        width: 55px; height: 85px; border-radius: 8px;
        top: 8%; right: 25%; left: auto; animation-delay: 1s;
        --start-rotation: -10deg; transform: rotate(-10deg);
    }
    .bg-shapes-mobile .shape:nth-child(5) {
        width: 75px; height: 50px; border-radius: 10px;
        bottom: 35%; right: 15%; left: auto; animation-delay: 3s;
        --start-rotation: 30deg; transform: rotate(30deg);
    }
    .bg-shapes-mobile .shape:nth-child(6) {
        width: 65px; height: 65px; border-radius: 14px;
        top: 38%; left: 5%; animation-delay: 5s;
        --start-rotation: -15deg; transform: rotate(-15deg);
    }
    
    @keyframes float-shapes {
        0%, 100% { transform: translateY(0) rotate(var(--start-rotation, 0deg)); }
        50% { transform: translateY(-15px) rotate(calc(var(--start-rotation, 0deg) + 180deg)); }
    }
}

/* Navbar Principal - Simplificada */
.navbar {
    background-color: #fff !important;
    box-shadow: var(--shadow);
    padding: calc(0.5rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) calc(0.5rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    min-height: var(--navbar-height);
    margin-bottom: 2rem;
}

.navbar .container-fluid {
    position: relative;
    display: flex;
    align-items: center;
}

.navbar-brand {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.app-navbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.navbar-brand i {
    margin-right: 0.5rem;
}

.navbar-brand img.navbar-logo {
    height: 52px;
    width: auto;
    max-width: 220px;
    object-fit: contain;
    vertical-align: middle;
}

.user-welcome {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color);
    font-weight: 500;
    min-width: 0;
}

.badge-role {
    background-color: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.8rem;
}

.navbar .btn-light,
.navbar-logout-btn {
    background-color: var(--secondary-color);
    border: 1px solid var(--border-light);
    color: var(--text-color);
    padding: 0.375rem 0.75rem;
    border-radius: var(--border-radius);
    text-decoration: none;
    transition: var(--transition);
}

.navbar .btn-light:hover,
.navbar-logout-btn:hover {
    background-color: #e9ecef;
    color: var(--text-color);
}

.navbar .btn-light i,
.navbar-logout-btn i {
    margin-right: 0.25rem;
}

/* Espaçamento para o conteúdo (inclui safe-area para notch) */
body,
.main-container {
    padding-top: calc(var(--navbar-height) + env(safe-area-inset-top));
}

/* Compatibilidade com Bootstrap */
.navbar.bg-light {
    background-color: #fff !important;
}

.navbar .container-fluid {
    padding-left: 0;
    padding-right: 0;
}

/* Garantir que os elementos do navbar fiquem alinhados */
.app-navbar-actions {
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .app-navbar-actions {
        gap: 0.3rem;
    }
}

@media (max-width: 576px) {
    .app-navbar-actions {
        gap: 0.25rem;
    }
}

@media (max-width: 480px) {
    .app-navbar-actions {
        gap: 0.2rem;
    }
}

/* Responsividade - Mobile: logo a esquerda, nome + tipo + sair a direita */
@media (max-width: 768px) {
    :root {
        --navbar-height: 60px;
    }
    
    .navbar {
        padding: calc(0.5rem + env(safe-area-inset-top)) calc(0.5rem + env(safe-area-inset-right)) calc(0.5rem + env(safe-area-inset-bottom)) calc(0.5rem + env(safe-area-inset-left)) !important;
        min-height: var(--navbar-height);
    }
    
    .navbar .container-fluid {
        justify-content: space-between;
        gap: 0.5rem;
    }
    
    .navbar-brand {
        position: static;
        transform: none;
        font-size: 0.95rem;
        flex-shrink: 0;
        order: 1;
        margin-left: 1.25rem;
    }
    
    .navbar-brand img.navbar-logo {
        height: 42px;
        max-width: 140px;
    }
    
    .app-navbar-actions {
        margin-left: auto;
        order: 2;
        flex-shrink: 1;
        min-width: 0;
        flex-direction: row;
        align-items: flex-end;
        justify-content: center;
        gap: 0.35rem;
    }

    .user-welcome {
        display: flex;
        align-items: center;
        gap: 0.35rem;
        flex-wrap: nowrap;
        min-width: 0;
    }
    
    .user-welcome .user-name {
        display: inline-block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100px;
        flex-shrink: 1;
    }
    
    .navbar-brand i {
        font-size: 0.9rem;
    }
    
    .user-welcome {
        font-size: 0.8rem;
        flex-direction: row;
        align-items: center;
        gap: 0.3rem;
        flex-wrap: nowrap;
    }
    
    .user-welcome i {
        font-size: 0.75rem;
    }
    
    .badge-role {
        font-size: 0.65rem;
        padding: 0.12rem 0.3rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .navbar .btn-light,
    .navbar-logout-btn {
        padding: 0.25rem 0.45rem;
        font-size: 0.78rem;
        flex-shrink: 0;
    }
}

@media (max-width: 576px) {
    :root {
        --navbar-height: 56px;
    }
    
    .navbar {
        padding: calc(0.4rem + env(safe-area-inset-top)) calc(0.4rem + env(safe-area-inset-right)) calc(0.4rem + env(safe-area-inset-bottom)) calc(0.4rem + env(safe-area-inset-left)) !important;
        min-height: var(--navbar-height);
    }
    
    .navbar-brand {
        font-size: 0.8rem;
        margin-left: 1rem;
    }
    
    .navbar-brand img.navbar-logo {
        height: 36px;
        max-width: 130px;
    }
    
    .navbar-brand i {
        font-size: 0.75rem;
    }
    
    .user-welcome {
        font-size: 0.7rem;
        flex-direction: row;
        align-items: center;
        gap: 0.25rem;
        flex-wrap: nowrap;
    }

    .user-welcome .user-name {
        max-width: 120px;
    }
    
    .user-welcome i {
        font-size: 0.65rem;
    }
    
    .badge-role {
        font-size: 0.6rem;
        padding: 0.08rem 0.2rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .navbar .btn-light,
    .navbar-logout-btn {
        padding: 0.18rem 0.35rem;
        font-size: 0.72rem;
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    :root {
        --navbar-height: 52px;
    }
    
    .navbar {
        padding: calc(0.35rem + env(safe-area-inset-top)) calc(0.35rem + env(safe-area-inset-right)) calc(0.35rem + env(safe-area-inset-bottom)) calc(0.35rem + env(safe-area-inset-left)) !important;
        min-height: var(--navbar-height);
    }
    
    .navbar-brand {
        font-size: 0.75rem;
        margin-left: 1rem;
    }
    
    .navbar-brand img.navbar-logo {
        height: 32px;
        max-width: 110px;
    }
    
    .navbar-brand i {
        font-size: 0.7rem;
    }
    
    .user-welcome {
        font-size: 0.65rem;
        flex-direction: row;
        align-items: center;
        gap: 0.2rem;
        flex-wrap: nowrap;
    }

    .user-welcome .user-name {
        max-width: 96px;
    }
    
    .user-welcome i {
        font-size: 0.6rem;
    }
    
    .badge-role {
        font-size: 0.55rem;
        padding: 0.06rem 0.15rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .navbar .btn-light,
    .navbar-logout-btn {
        padding: 0.15rem 0.28rem;
        font-size: 0.68rem;
        flex-shrink: 0;
    }

}

/* Estilos Globais para Componentes - Glass transparent (como login de inicio) */
.card {
    background: var(--glass-card-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    transition: var(--transition);
    border: 1px solid var(--glass-border);
}

.card-header {
    background: var(--glass-card-header-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.card-body {
    padding: 1.5rem;
}

/* Header of each post/turno card - same light style for Turnos Disponiveis, Turnos Apanhados, future posts */
.item-card-header {
    background: var(--glass-item-card-header-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    padding: 1.5rem;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    color: var(--text-color);
    position: relative;
}

.table {
    width: 100%;
    margin-bottom: 0;
}

.table thead th {
    background: var(--glass-card-header-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 2px solid rgba(255, 255, 255, 0.25);
    color: var(--text-color);
    font-weight: 600;
    padding: 0.75rem;
    text-align: left;
    vertical-align: middle;
}

.table tbody tr {
    border-bottom: 1px solid var(--border-light);
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(6px);
}

.btn {
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: 500;
}

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

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

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

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

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

.badge {
    border-radius: 0.375rem;
    font-weight: 500;
}

.modal-content {
    border-radius: var(--border-radius-lg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border-light);
    padding: 1rem 1.5rem;
}

.alert {
    border-radius: var(--border-radius);
    border: none;
    padding: 0.75rem 1rem;
}

.dropdown-menu {
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
}

.dropdown-item:hover {
    background-color: var(--bg-light);
}

/* Responsividade para componentes */
@media (max-width: 768px) {
    .card,
    .modal-content {
        margin: 0.5rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .form-control,
    .btn {
        font-size: 0.9rem;
    }
    
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-header,
    .modal-footer {
        padding: 0.75rem 1rem;
    }
}

/* Table scroll horizontal - touch devices */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ========================================
   TABELAS MOBILE - Layout em cards (sem scroll horizontal)
   Em mobile, cada linha vira um card com info empilhada verticalmente
   ======================================== */
@media (max-width: 768px) {
    .table-mobile-cards {
        overflow-x: visible;
    }
    
    .table-mobile-cards table {
        display: block;
    }
    
    .table-mobile-cards table thead {
        display: none;
    }
    
    .table-mobile-cards table tbody {
        display: block;
    }
    
    /* Uniform background (no alternating) - one dark/solid for info readability */
    .table-mobile-cards table tbody tr,
    .table-mobile-cards table.table-striped tbody tr,
    .table-mobile-cards table.table-striped tbody tr:nth-of-type(odd),
    .table-mobile-cards table.table-striped tbody tr:nth-of-type(even) {
        display: block;
        margin-bottom: 1rem;
        padding: 1rem;
        background: rgba(255, 255, 255, 0.5);
        backdrop-filter: blur(var(--glass-blur));
        -webkit-backdrop-filter: blur(var(--glass-blur));
        border: 1px solid var(--glass-border);
        border-radius: var(--border-radius);
        box-shadow: var(--shadow);
    }
    
    .table-mobile-cards table tbody tr[data-nome] {
        border-left: 4px solid var(--primary-color);
    }
    
    .table-mobile-cards table tbody td {
        display: block;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        font-size: 0.9rem;
    }
    
    .table-mobile-cards table tbody td:last-child {
        border-bottom: none;
        padding-top: 0.75rem;
    }
    
    .table-mobile-cards table tbody td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }

    /* Prevent email/link overflow - ellipsis for long text */
    .table-mobile-cards table tbody td {
        overflow: hidden;
    }
    .table-mobile-cards table tbody td a {
        display: inline-block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        vertical-align: bottom;
    }
    
    /* Action buttons: especificacoes em global-actions.css (como Gerir Fornecedores) */
    
    .table-mobile-cards table tbody tr td[colspan] {
        display: block;
        text-align: center;
        padding: 1.5rem;
    }
    
    .table-mobile-cards table tbody tr td[colspan]::before {
        content: none;
    }
}

/* ========================================
   FILTROS - MODO HAMBURGER MOBILE
   Regra geral: em mobile, filtros colapsados num botao expansivel
   ======================================== */
@media (max-width: 768px) {
    .filtros-container .filtros-toggle-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
        padding: 0.75rem 1rem;
        margin-bottom: 0;
        background: var(--primary-color);
        color: var(--text-light);
        border: none;
        border-radius: var(--border-radius);
        font-weight: 500;
        font-size: 0.95rem;
        cursor: pointer;
        transition: var(--transition);
    }
    
    .filtros-container .filtros-toggle-mobile:hover {
        background: var(--primary-hover);
        color: var(--text-light);
    }
    
    .filtros-container .filtros-toggle-mobile .fa-chevron-down {
        transition: transform 0.3s ease;
        margin-left: 0.25rem;
    }
    
    .filtros-container.filtros-expandido .filtros-toggle-mobile .fa-chevron-down {
        transform: rotate(180deg);
    }
    
    .filtros-container .filtros-inner {
        display: none;
        padding-top: 1rem;
        border-top: 1px solid var(--border-light);
        margin-top: 0.5rem;
    }
    
    .filtros-container.filtros-expandido .filtros-inner {
        display: block;
    }
}

@media (min-width: 769px) {
    .filtros-container .filtros-toggle-mobile {
        display: none;
    }
    
    .filtros-container .filtros-inner {
        display: block;
    }
}
