/* ============================================================
   Portal ICOR – CSS Principal
   ============================================================ */

:root {
    --sidebar-width:      260px;
    --sidebar-bg:         #1a1f2e;
    --sidebar-text:       #c8ccd8;
    --sidebar-hover:      rgba(255,255,255,.08);
    --sidebar-active:     rgba(255,255,255,.12);
    --sidebar-border:     rgba(255,255,255,.08);
    --topbar-height:      56px;
    --topbar-bg:          #fff;
    --topbar-border:      #e9ecef;
    --brand-primary:      #0d6efd;
    --body-bg:            #f4f6fb;
    --card-radius:        12px;
    --transition:         0.22s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body.portal-body {
    margin: 0;
    padding: 0;
    background: var(--body-bg);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    overflow-y: auto;
    transition: transform var(--transition);
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-brand {
    padding: 1.25rem 1rem;
    display: flex;
    align-items: center;
    text-decoration: none;
}
.sidebar-brand a { color: #fff; display: flex; align-items: center; gap: .5rem; }
.sidebar-logo { height: 36px; object-fit: contain; }
.sidebar-title { font-weight: 700; font-size: 1.1rem; color: #fff; letter-spacing: .5px; }

.sidebar-divider {
    border-color: var(--sidebar-border);
    margin: .25rem 1rem;
}

.sidebar-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,.35);
    padding: .75rem 1.25rem .25rem;
    font-weight: 600;
}

.sidebar-nav { padding: .25rem 0; }

.sidebar-item { list-style: none; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .9rem;
    border-radius: 0;
    transition: background var(--transition), color var(--transition);
    position: relative;
}
.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.sidebar-item.active > .sidebar-link {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}
.sidebar-item.active > .sidebar-link::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--mod-color, var(--brand-primary));
    border-radius: 0 3px 3px 0;
}

.sidebar-link i { font-size: 1.1rem; flex-shrink: 0; width: 20px; text-align: center; }

/* Utilizador no fundo */
.sidebar-user { border-top: 1px solid var(--sidebar-border); margin-top: auto; }
.sidebar-footer-link {
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 1.1rem;
    transition: color var(--transition), background var(--transition);
}
.sidebar-footer-link:hover { color: #fff; background: var(--sidebar-hover); }

.avatar-circle {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .95rem;
    flex-shrink: 0;
}

.badge-notify {
    position: absolute;
    top: 4px; right: 6px;
    font-size: .6rem;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    line-height: 16px;
    border-radius: 8px;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

.main-content.expanded {
    margin-left: 0;
}

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    position: sticky;
    top: 0;
    z-index: 999;
    gap: .5rem;
}

.topbar .breadcrumb-item a { color: var(--brand-primary); text-decoration: none; }
.topbar .breadcrumb-item a:hover { text-decoration: underline; }

.module-badge {
    font-size: .78rem;
    padding: .35rem .7rem;
    border-radius: 20px;
}

/* ---- Footer ---- */
.portal-footer {
    margin-top: auto;
    font-size: .8rem;
}

/* ============================================================
   AUTH
   ============================================================ */
body.auth-body {
    background: linear-gradient(135deg, #1a1f2e 0%, #0d6efd 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-wrapper {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 2rem 2.5rem;
}

.auth-logo img { max-height: 72px; }

/* ============================================================
   MODULE CARDS
   ============================================================ */
.module-card {
    border-radius: var(--card-radius);
    transition: transform .2s, box-shadow .2s;
    border-top: 4px solid var(--mod-color, #6c757d) !important;
}
.module-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,.12) !important;
}

.module-icon-circle {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

/* ============================================================
   ADMIN / TABLES
   ============================================================ */
.table th { font-weight: 600; font-size: .85rem; }
.table td { font-size: .875rem; vertical-align: middle; }

.card {
    border-radius: var(--card-radius);
}

.card-header-portal {
    background: #fff;
    border-bottom: 2px solid #e9ecef;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}
.card-header-portal h5 { margin: 0; font-size: 1rem; font-weight: 700; }

/* ============================================================
   MODULE THEMES (cor de topo / accent)
   ============================================================ */
.module-clinica    { --mod-color: #0d6efd; }
.module-marcacoes  { --mod-color: #198754; }
.module-seguradoras{ --mod-color: #6f42c1; }
.module-farmacia   { --mod-color: #dc3545; }
.module-qualidade  { --mod-color: #ffc107; }
.module-suporte    { --mod-color: #fd7e14; }
.module-admin      { --mod-color: #343a40; }

.module-header {
    padding: 1rem 1.25rem;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    color: #fff;
    display: flex;
    align-items: center;
    gap: .75rem;
}
.module-header i { font-size: 1.5rem; }
.module-header h4 { margin: 0; font-weight: 700; }

/* ============================================================
   UTILITÁRIOS
   ============================================================ */
.min-w-0 { min-width: 0; }
.cursor-pointer { cursor: pointer; }

.alert-sm { font-size: .875rem; padding: .5rem .75rem; }

/* Scroll fino */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.2); border-radius: 3px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-overlay {
        display: block !important;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
}
