/* ============================================================
   FarmaControl SUS — Xambioá/TO
   Stylesheet Principal
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --primary-dark: #154360;
    --secondary: #148f77;
    --accent: #e67e22;
    --danger: #c0392b;
    --warning: #f39c12;
    --success: #27ae60;
    --info: #2980b9;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-500: #64748b;
    --gray-700: #334155;
    --gray-900: #0f172a;
    --sidebar-w: 260px;
    --header-h: 64px;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .1), 0 1px 2px rgba(0, 0, 0, .06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px rgba(0, 0, 0, .06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px rgba(0, 0, 0, .07);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.layout {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--primary-dark);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: transform .3s ease;
}

.sidebar-logo {
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.sidebar-logo-text {
    color: #fff;
}

.sidebar-logo-text .title {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
}

.sidebar-logo-text .subtitle {
    font-size: 11px;
    color: rgba(255, 255, 255, .6);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.sidebar-section {
    padding: 8px 18px 4px;
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, .4);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: rgba(255, 255, 255, .75);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .2s, color .2s;
    border-radius: 0 8px 8px 0;
    margin: 1px 8px 1px 0;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.sidebar-nav a .icon {
    font-size: 18px;
    width: 22px;
    text-align: center;
}

.sidebar-nav a.public-link {
    background: rgba(39, 174, 96, .15);
    color: #2ecc71;
    margin: 8px;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12.5px;
    border: 1px solid rgba(46, 204, 113, .25);
}

.sidebar-nav a.public-link:hover {
    background: rgba(39, 174, 96, .3);
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, .1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-footer .avatar {
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, .15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
}

.sidebar-footer .user-info {
    flex: 1;
}

.sidebar-footer .user-info .name {
    font-size: 12.5px;
    color: #fff;
    font-weight: 600;
}

.sidebar-footer .user-info .nivel {
    font-size: 11px;
    color: rgba(255, 255, 255, .5);
}

.sidebar-footer .logout {
    color: rgba(255, 255, 255, .5);
    text-decoration: none;
    font-size: 18px;
}

.sidebar-footer .logout:hover {
    color: #fff;
}

/* MAIN CONTENT */
.main-wrapper {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* TOPBAR */
.topbar {
    height: var(--header-h);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}

.topbar-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
}

.topbar-meta {
    font-size: 12px;
    color: var(--gray-500);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--primary);
}

/* PAGE CONTENT */
.page-content {
    padding: 24px;
    flex: 1;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
}

.page-header p {
    color: var(--gray-500);
    margin-top: 4px;
    font-size: 13px;
}

/* ============================================================
   CARDS
   ============================================================ */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: box-shadow .2s, transform .2s;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.card-stat {
    display: flex;
    align-items: center;
    gap: 16px;
}

.card-stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.card-stat-icon.blue {
    background: #dbeafe;
}

.card-stat-icon.yellow {
    background: #fef3c7;
}

.card-stat-icon.red {
    background: #fee2e2;
}

.card-stat-icon.green {
    background: #dcfce7;
}

.card-stat-icon.purple {
    background: #ede9fe;
}

.card-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
}

.card-stat-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 3px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
}

.table-card-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-900);
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead th {
    background: var(--gray-50);
    padding: 10px 14px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--gray-50);
}

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-regular {
    background: #dcfce7;
    color: #166534;
}

.badge-baixo {
    background: #fef3c7;
    color: #92400e;
}

.badge-critico {
    background: #fee2e2;
    color: #991b1b;
}

.badge-zerado {
    background: #f1f5f9;
    color: #475569;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 9px 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--gray-900);
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, .12);
}

.form-group textarea {
    min-height: 90px;
    resize: vertical;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background .2s, box-shadow .2s, transform .1s;
}

.btn:active {
    transform: scale(.98);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #219a52;
}

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-warning:hover {
    background: #d68910;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #a93226;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12.5px;
}

.btn-public {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: #fff;
}

.btn-public:hover {
    background: linear-gradient(135deg, #219a52, #27ae60);
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border-left: 4px solid #22c55e;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

/* ============================================================
   FILTERS / SEARCH
   ============================================================ */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filters-bar input,
.filters-bar select {
    padding: 8px 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13.5px;
    background: #fff;
    color: var(--gray-900);
    transition: border-color .2s;
}

.filters-bar input:focus,
.filters-bar select:focus {
    outline: none;
    border-color: var(--primary-light);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, .25);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header img {
    width: 80px;
    margin-bottom: 12px;
}

.login-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}

.login-header p {
    font-size: 12.5px;
    color: var(--gray-500);
    margin-top: 4px;
}

.login-divider {
    text-align: center;
    margin: 20px 0;
    color: var(--gray-300);
}

/* ============================================================
   PUBLIC REPORT
   ============================================================ */
.public-page {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--gray-50);
    min-height: 100vh;
}

.public-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    padding: 24px 40px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.public-header img {
    width: 80px;
}

.public-header-text h1 {
    font-size: 20px;
    font-weight: 700;
}

.public-header-text p {
    font-size: 13px;
    opacity: .8;
    margin-top: 4px;
}

.public-lei-bar {
    background: #1a5276;
    color: rgba(255, 255, 255, .85);
    font-size: 12.5px;
    padding: 10px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.public-lei-bar a {
    color: #5dade2;
    font-weight: 600;
}

.public-content {
    max-width: 1100px;
    margin: 32px auto;
    padding: 0 24px 40px;
}

.public-meta-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.public-meta-item {
    flex: 1;
    min-width: 150px;
}

.public-meta-item .label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-500);
    letter-spacing: .06em;
}

.public-meta-item .value {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 3px;
}

.public-footer {
    text-align: center;
    padding: 24px;
    color: var(--gray-500);
    font-size: 12px;
    border-top: 1px solid var(--gray-200);
    margin-top: 32px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .btn-menu-toggle {
        display: block;
    }

    .cards-grid {
        grid-template-columns: 1fr 1fr;
    }

    .page-content {
        padding: 16px;
    }

    .public-header {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }

    .public-lei-bar {
        padding: 10px 16px;
    }
}

@media (max-width: 480px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-content {
    animation: fadeIn .25s ease;
}

/* ============================================================
   OVERLAY MOBILE
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    z-index: 99;
}

.sidebar-overlay.open {
    display: block;
}

/* Print */
@media print {

    .sidebar,
    .topbar,
    .btn,
    .no-print {
        display: none !important;
    }

    .main-wrapper {
        margin-left: 0;
    }

    body {
        background: #fff;
    }

    .page-content {
        padding: 0;
    }
}