@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css");
@font-face {
    font-family: 'Product Sans';
    font-style: normal;
    font-weight: normal;
    src: local('Product Sans'), url('../assets/fonts/product_sans.ttf') format('truetype');
}

:root {
    --bg-deep: #1D052B;
    --card-bg: #300B44;
    --card-hover: #3E105A;
    --purple-primary: #7A1CAC;
    --purple-deep: #551378;
    --text-white: #FFFFFF;
    --text-muted: #D0C0E0;
    --accent-green: #4E9F3D;
    --accent-red: #FF6B6B;
    --accent-yellow: #FFD93D;
    --border-color: #551378;
    --sidebar-w: 260px;
    --icon-size: 24px;
    --icon-home: 72px;
    --bs-body-bg: var(--bg-deep);
    --bs-body-color: var(--text-white);
    --bs-border-color: var(--border-color);
}

* {
    box-sizing: border-box;
    font-family: 'Product Sans', sans-serif;
}

html {
    -webkit-text-size-adjust: 100%
}

body {
    background: var(--bg-deep) !important;
    color: var(--text-white) !important;
    font-family: 'Product Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
    min-height: 100dvh
}

/* ===== Layout ===== */
.app-container-box {
    display: none;
    min-height: 100dvh;
    width: 100%
}

.sidebar-desktop {
    position: sticky;
    top: 0;
    height: 100dvh;
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: none;
    flex-direction: column;
    overflow-y: auto
}

@media (min-width: 992px) {
    .sidebar-desktop {
        display: flex
    }

    .mobile-toggle {
        display: none !important
    }
}

.offcanvas.sidebar-offcanvas {
    background: var(--card-bg);
    color: var(--text-white);
    border-right: 1px solid var(--border-color);
    width: min(280px, 85vw)
}

.sidebar-offcanvas .offcanvas-header {
    border-bottom: 1px solid var(--border-color)
}

.main-content-col {
    flex: 1 1 auto;
    min-width: 0;
    background: var(--bg-deep);
    display: flex;
    flex-direction: column
}

.brand {
    font-weight: 800;
    letter-spacing: .3px
}

.brand img {
    height: var(--icon-size);
    width: var(--icon-size);
}

.brand span {
    color: var(--purple-primary);
    filter: brightness(1.6)
}

.icon {
    align-content: center;
    display: flex;
    height: var(--icon-home);
    justify-content: center;
    margin-left: auto !important;
    margin-right: auto !important;
    width: var(--icon-home);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(29, 5, 43, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    padding: .75rem 1rem
}

@media (min-width: 768px) {
    .topbar {
        padding: 1rem 1.5rem
    }
}

.topbar h1 {
    font-size: clamp(1.05rem, 2.5vw, 1.5rem);
    margin: 0;
    font-weight: 700
}

.page-pad {
    padding: 1rem
}

@media (min-width: 768px) {
    .page-pad {
        padding: 1.5rem
    }
}

@media (min-width: 1400px) {
    .page-pad {
        padding: 2rem;
        max-width: 1600px;
        width: 100%;
        margin-inline: auto
    }
}

/* ===== Nav ===== */
.nav-link {
    color: var(--text-muted) !important;
    font-weight: 500;
    border-radius: 10px;
    padding: .7rem 1rem;
    transition: all .25s ease;
    display: flex;
    align-items: center;
    gap: .6rem;
    min-height: 44px
}

.nav-link:hover, .nav-link.active {
    background: var(--purple-primary) !important;
    color: var(--text-white) !important
}

.nav-link i {
    font-size: 1.1rem
}

.sidebar-footer {
    border-top: 1px solid var(--border-color)
}

.admin-email-text {
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all
}

.border-purple {
    border-color: var(--border-color) !important
}

.status-badge {
    background: var(--purple-deep);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    margin-right: 6px;
    box-shadow: 0 0 6px var(--accent-green)
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 14px !important;
    color: var(--text-white) !important;
    transition: transform .2s, background .2s
}

.stat-card:hover {
    background: var(--card-hover) !important;
    transform: translateY(-2px)
}

.card h3 {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 10px
}

.card .value {
    font-size: clamp(1.4rem, 4vw, 1.9rem);
    font-weight: 700;
    color: var(--text-white);
    word-break: break-word
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--purple-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex: 0 0 auto
}

.card-style {
    text-align: center;
    width: 100%;
    max-width: 420px;
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 16px !important;
    color: var(--text-white) !important
}

.progress {
    background: var(--bg-deep);
    height: 8px;
    border-radius: 8px
}

.progress-bar {
    background: linear-gradient(90deg, var(--purple-primary), #b04be0)
}

.section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1rem
}

@media (min-width: 768px) {
    .section {
        padding: 1.5rem
    }
}

.section h2 {
    font-size: clamp(1rem, 2.2vw, 1.2rem);
    color: var(--text-white);
    font-weight: 700
}

.section-desc {
    color: var(--text-muted);
    font-size: 14px
}

/* ===== Tabs ===== */
.tab-content {
    display: none
}

.tab-content.active {
    display: block;
    animation: fade .25s ease
}

@keyframes fade {
    from {
        opacity: 0;
        transform: translateY(6px)
    }
    to {
        opacity: 1;
        transform: none
    }
}

/* ===== Tables ===== */
.table-responsive {
    border-radius: 10px
}

table {
    color: var(--text-white) !important;
    --bs-table-bg: transparent;
    --bs-table-color: #fff;
    margin-bottom: 0
}

th, td {
    border-color: var(--border-color) !important;
    color: var(--text-white) !important;
    vertical-align: middle;
    background: transparent !important
}

th {
    background: rgba(0, 0, 0, .3) !important;
    color: var(--text-muted) !important;
    font-weight: 600;
    white-space: nowrap;
    font-size: 13px
}

tbody tr:hover td {
    background: var(--card-hover) !important
}

.table-center {
    text-align: center
}

.cell-break {
    word-break: break-all;
    font-size: 12px;
    color: var(--text-muted)
}

/* Mobile: tabela vira lista de cartões */
@media (max-width: 767.98px) {
    table.responsive-cards thead {
        display: none
    }

    table.responsive-cards, table.responsive-cards tbody, table.responsive-cards tr, table.responsive-cards td {
        display: block;
        width: 100%
    }

    table.responsive-cards tr {
        border: 1px solid var(--border-color);
        border-radius: 12px;
        margin-bottom: .75rem;
        padding: .4rem .75rem;
        background: var(--bg-deep)
    }

    table.responsive-cards td {
        border: 0 !important;
        border-bottom: 1px dashed rgba(255, 255, 255, .08) !important;
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        text-align: right;
        padding: .5rem 0
    }

    table.responsive-cards td:last-child {
        border-bottom: 0 !important;
        justify-content: flex-end
    }

    table.responsive-cards td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-weight: 600;
        font-size: 12px;
        text-transform: uppercase;
        text-align: left;
        flex: 0 0 auto
    }

    table.responsive-cards td.table-center {
        display: block;
        text-align: center
    }

    table.responsive-cards td.table-center::before {
        content: none
    }

    table.responsive-cards td .cell-break {
        max-width: 65%
    }
}

/* ===== Forms ===== */
.form-floating > .form-control, .form-floating > .form-control-plaintext, .form-floating > textarea.form-control {
    background: var(--bg-deep) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-white) !important;
    border-radius: 10px !important
}

.form-floating > label {
    color: var(--text-muted) !important
}

.form-floating > .form-control:focus {
    background: var(--bg-deep) !important;
    border-color: var(--purple-primary) !important;
    box-shadow: 0 0 0 .25rem rgba(122, 28, 172, .3) !important
}

.form-floating > .form-control:not(:placeholder-shown) ~ label, .form-floating > .form-control:focus ~ label {
    color: var(--text-muted) !important
}

.form-floating > .form-control:-webkit-autofill {
    -webkit-text-fill-color: #fff;
    -webkit-box-shadow: 0 0 0 1000px var(--bg-deep) inset
}

input.form-control, textarea.form-control {
    background: var(--bg-deep) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-white) !important;
    border-radius: 10px !important;
    font-size: 16px
}

input.form-control:focus, textarea.form-control:focus {
    border-color: var(--purple-primary) !important;
    box-shadow: 0 0 0 .25rem rgba(122, 28, 172, .3) !important
}

.form-control::placeholder {
    color: rgba(208, 192, 224, .5)
}

textarea.form-control {
    min-height: 110px
}

.btn {
    min-height: 44px;
    border-radius: 10px !important;
    font-weight: 600
}

.btn-primary {
    background: var(--purple-primary) !important;
    border: none !important;
    font-weight: bold
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--purple-deep) !important
}

.btn-danger {
    background: var(--accent-red) !important;
    border: none !important;
    color: #1D052B !important
}

.btn-danger:hover {
    filter: brightness(.9)
}

.btn-sm {
    min-height: 36px
}

.btn-outline-light {
    border-color: var(--border-color) !important;
    color: var(--text-muted) !important
}

.btn-outline-light:hover {
    background: var(--purple-primary) !important;
    color: #fff !important
}

.btn-close {
    filter: invert(1)
}

/* ===== Logs ===== */
.log-entry {
    margin-bottom: 4px;
    word-break: break-word;
    border-bottom: 1px dashed rgba(255, 255, 255, .05);
    padding-bottom: 2px
}

.log-info {
    color: var(--text-muted)
}

.log-warn {
    color: var(--accent-yellow)
}

.log-error {
    color: var(--accent-red);
    font-weight: bold
}

.log-init-text {
    color: var(--text-muted)
}

.system-logs-box {
    background: var(--bg-deep);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    height: clamp(260px, 55dvh, 500px);
    overflow-y: auto;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12px
}

@media (min-width: 768px) {
    .system-logs-box {
        font-size: 13px;
        padding: 16px
    }
}

/* ===== Login ===== */
.sign-in-overlay {
    align-items: center;
    background: radial-gradient(circle at top, var(--card-bg), var(--bg-deep) 70%);
    display: flex;
    min-height: 100dvh;
    justify-content: center;
    position: fixed;
    inset: 0;
    z-index: 9999;
    padding: 1rem;
    overflow-y: auto
}

.login-error-text {
    color: var(--accent-red);
    margin-top: 12px;
    font-size: 13px;
    min-height: 1em;
    word-break: break-word
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px
}

::-webkit-scrollbar-thumb {
    background: var(--purple-deep);
    border-radius: 8px
}

::-webkit-scrollbar-track {
    background: transparent
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important
    }
}
