/**
 * TV WANDAM — Componentes globais da aplicação
 */

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background: var(--brand-bg);
    color: var(--brand-text);
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 28px 32px;
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    transition: margin var(--transition);
}

@media (max-width: 992px) {
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 80px 16px 24px;
    }
}

/* ── Sidebar ── */
.tv-sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    background: var(--brand-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,.06);
}

.tv-sidebar::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--brand-gradient);
}

.tv-sidebar-logo {
    padding: 20px 16px 12px;
    text-align: center;
    flex-shrink: 0;
}

.tv-sidebar-logo-img {
    width: 110px;
    height: 110px;
    max-width: 110px;
    object-fit: contain;
    border-radius: 50%;
    display: block;
    margin: 0 auto 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}

.tv-sidebar-logo img {
    max-width: 110px;
    width: 110px;
    height: auto;
    filter: none;
}

.tv-sidebar-tagline {
    font-size: .62rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgba(255,255,255,.45);
    margin-top: 8px;
    line-height: 1.3;
}

.tv-sidebar-profile {
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    transition: background .2s ease;
}

.tv-sidebar-profile:hover {
    background: rgba(255, 255, 255, .08);
}

.tv-sidebar-profile-name {
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    line-height: 1.3;
    word-break: break-word;
    flex: 1;
    min-width: 0;
}

.tv-sidebar-footer {
    padding: 14px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.menu-user-avatar {
    flex-shrink: 0;
}

.tv-mobile-toggle {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1100;
    background: var(--brand-sidebar) !important;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,.12) !important;
    border-radius: var(--radius-sm) !important;
}

/* ── Navegação ── */
.nav-link {
    border-radius: var(--radius-sm) !important;
    transition: var(--transition);
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
}

.nav-link:hover:not(.active-bc) {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.active-bc {
    background: var(--brand-gradient) !important;
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(67,160,71,.25);
}

.collapse .nav-link.text-brand { color: var(--brand-green) !important; }

.custom-scroll::-webkit-scrollbar { width: 4px; }
.custom-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.12);
    border-radius: 10px;
}

/* ── Cards ── */
.card-custom,
.tv-card {
    border: none;
    border-radius: var(--radius-xl);
    background: var(--brand-surface);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    height: 100%;
    transition: transform var(--transition), box-shadow var(--transition);
}

.card-custom:hover,
.tv-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.tv-kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.tv-kpi-icon--green { background: rgba(67,160,71,.12); color: var(--brand-green); }
.tv-kpi-icon--red   { background: rgba(229,57,53,.12); color: var(--brand-red); }
.tv-kpi-icon--yellow{ background: rgba(251,192,45,.15); color: #B8860B; }
.tv-kpi-icon--dark  { background: rgba(26,26,26,.08); color: var(--brand-dark); }

.tv-kpi-card {
    position: relative;
    border: 1px solid var(--brand-border);
    border-radius: var(--radius-xl);
    background: var(--brand-surface);
    padding: 22px 22px 20px;
    height: 100%;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
}

.tv-kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--kpi-accent, var(--brand-green));
}

.tv-kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.tv-kpi-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.tv-kpi-card__label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--brand-text-muted);
    margin-bottom: 6px;
}

.tv-kpi-card__value {
    font-size: clamp(1.35rem, 2vw, 1.65rem);
    font-weight: 800;
    line-height: 1.15;
    color: var(--brand-text);
    letter-spacing: -0.02em;
}

.tv-kpi-card__value small {
    font-size: 0.52em;
    font-weight: 600;
    opacity: 0.5;
}

.tv-kpi-card__month {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 50px;
    background: rgba(0, 0, 0, .05);
    color: var(--brand-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.tv-kpi-card--green { --kpi-accent: var(--brand-green); }
.tv-kpi-card--green .tv-kpi-card__value { color: var(--brand-green-dark); }

.tv-kpi-card--red { --kpi-accent: var(--brand-red); }
.tv-kpi-card--red .tv-kpi-card__value { color: var(--brand-red); }

.tv-kpi-card--dark { --kpi-accent: var(--brand-dark); }
.tv-kpi-card--dark .tv-kpi-card__value { color: var(--brand-dark); }

/* ── Botões ── */
.btn-tv,
.btn-bc {
    background: var(--brand-gradient);
    color: #fff;
    border: none;
    font-weight: 700;
    border-radius: var(--radius-md);
    transition: var(--transition);
    letter-spacing: .02em;
}

.btn-tv:hover,
.btn-bc:hover {
    color: #fff;
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(67,160,71,.25);
}

.btn-tv-outline {
    border: 2px solid var(--brand-green);
    color: var(--brand-green);
    background: transparent;
    font-weight: 600;
    border-radius: var(--radius-md);
}

.btn-tv-outline:hover {
    background: var(--brand-green);
    color: #fff;
}

/* ── Tabelas ── */
.table-tv thead th {
    background: var(--brand-dark) !important;
    color: #fff !important;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    border: none;
    padding: 12px;
}

.table-tv tbody tr:hover { background: var(--brand-gradient-soft); }

/* ── Formulários ── */
.form-control:focus,
.form-select:focus {
    border-color: var(--brand-green);
    box-shadow: 0 0 0 .2rem rgba(67,160,71,.15);
}

/* ── Secções ── */
.section-title {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .12em;
    color: var(--brand-text-muted);
    text-transform: uppercase;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title i { color: var(--brand-green); }

/* ── Avatar utilizador ── */
.tv-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: .85rem;
}

/* ── Dropdown notificações ── */
.dropdown-menu-dark .dropdown-item:hover {
    background: var(--brand-green-dark);
}

/* ── Dashboard específico ── */
.tv-dashboard-hero {
    background: var(--brand-surface);
    border-radius: var(--radius-xl);
    padding: 28px 32px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid transparent;
    border-image: var(--brand-gradient) 1;
    margin-bottom: 28px;
}

.tv-quick-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    border-radius: var(--radius-lg);
    background: var(--brand-bg);
    text-decoration: none;
    color: var(--brand-text);
    transition: var(--transition);
    font-size: .8rem;
    font-weight: 600;
}

.tv-quick-link:hover {
    background: var(--brand-gradient-soft);
    color: var(--brand-green-dark);
    transform: translateY(-2px);
}

.tv-quick-link i {
    font-size: 1.4rem;
    color: var(--brand-green);
}

.month-watermark {
    position: absolute;
    right: -8px;
    bottom: -12px;
    font-size: 72px;
    font-weight: 900;
    color: rgba(0,0,0,.03);
    text-transform: uppercase;
    pointer-events: none;
}

.scroll-container {
    display: flex;
    overflow-x: auto;
    gap: 16px;
    padding-bottom: 8px;
    scrollbar-width: thin;
}

.card-producao {
    min-width: 280px;
    background: var(--brand-surface);
    border-radius: var(--radius-lg);
    border-left: 5px solid var(--brand-red);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

/* ── Animações de entrada do dashboard ── */
@keyframes tvDashUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes tvDashSlideRight {
    from {
        opacity: 0;
        transform: translateX(-14px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.tv-dash-page .main-content {
    animation: tvDashFadeIn .45s ease forwards;
}

.tv-dash-enter {
    opacity: 0;
    animation: tvDashUp .72s cubic-bezier(.22, 1, .36, 1) forwards;
    animation-delay: var(--tv-delay, 0s);
}

.tv-dash-enter--slide {
    opacity: 0;
    animation: tvDashSlideRight .65s cubic-bezier(.22, 1, .36, 1) forwards;
    animation-delay: var(--tv-delay, 0s);
}

.tv-dash-kpi.tv-kpi-card:hover {
    transform: translateY(-4px);
}

@media (prefers-reduced-motion: reduce) {
    .tv-dash-page .main-content,
    .tv-dash-enter,
    .tv-dash-enter--slide {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ── Rodapé app ── */
.tv-app-footer {
    text-align: center;
    padding: 16px;
    font-size: .75rem;
    color: var(--brand-text-muted);
}

.tv-developer-credit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .78rem;
    font-weight: 600;
    color: var(--brand-text-muted);
    text-decoration: none;
    transition: color .2s ease, transform .2s ease;
    line-height: 1.2;
}

.tv-developer-credit i {
    color: #25D366;
    font-size: 1.15rem;
    line-height: 1;
}

.tv-developer-credit:hover {
    color: #128C7E;
    transform: translateY(-1px);
}

.tv-developer-credit:hover i {
    color: #128C7E;
}

.tv-developer-credit--light {
    color: rgba(255, 255, 255, .82);
}

.tv-developer-credit--light:hover {
    color: #fff;
}

.tv-developer-credit-wrap {
    display: flex;
    justify-content: center;
    padding: 12px 16px;
}

.tv-developer-credit-wrap--fixed {
    position: fixed;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    pointer-events: none;
}

.tv-developer-credit-wrap--fixed .tv-developer-credit {
    pointer-events: auto;
    background: rgba(255, 255, 255, .92);
    padding: 8px 14px;
    border-radius: 50px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
    border: 1px solid var(--brand-border);
}

.tv-developer-credit-wrap--light .tv-developer-credit {
    background: rgba(0, 0, 0, .22);
    border-color: rgba(255, 255, 255, .15);
    color: rgba(255, 255, 255, .9);
}

.tv-alert {
    border-radius: var(--radius-md) !important;
    padding: 12px 16px !important;
    margin-bottom: 1rem;
}

.tv-alert-icon {
    font-size: 1.15rem;
    line-height: 1.4;
    margin-top: 1px;
}

.alert-success .tv-alert-icon { color: var(--brand-green-dark); }
.alert-danger .tv-alert-icon { color: var(--brand-red); }
.alert-info .tv-alert-icon { color: #2563EB; }

.tv-alert-text {
    line-height: 1.45;
    font-size: .9rem;
    font-weight: 500;
}

/* ── Utilitários ── */
.text-brand { color: var(--brand-green) !important; }
.bg-brand-gradient { background: var(--brand-gradient) !important; }
.border-brand-gradient {
    border: 2px solid transparent;
    background-image: linear-gradient(#fff,#fff), var(--brand-gradient);
    background-origin: border-box;
    background-clip: padding-box, border-box;
}
