﻿:root {
    font-size: 18px;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-dark: #111827;
    --sidebar-bg: #18181b;
    --bg-darker: #0f172a;
    --bg-light: #f3f4f6;
    --text-light: #f9fafb;
    --text-dark: #1f2937;
    --sidebar-width: 220px;
    --header-height: 64px;
    --transition: all 0.3s ease;
}

/* Responsive Font Sizes */
@media (max-width: 1366px) {
    :root {
        font-size: 16px;
    }
}

@media (max-width: 1024px) {
    :root {
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    :root {
        font-size: 10px;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    transition: var(--transition);
    height: 100vh;
    /* Ensure full height */
}

.sidebar nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    /* Important for flex containers */
    padding-right: 4px;
    /* Avoid scrollbar overlapping content */
}

/* Custom Scrollbar for Sidebar */
.sidebar nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar nav::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.sidebar nav::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.logo {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: white;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    padding: 1rem 0;
}

.logo:hover {
    opacity: 0.95;
}

.logo:hover .logo-icon {
    transform: scale(1.05);
}

.logo-icon {
    width: 120px;
    height: 120px;
    object-fit: contain;
    transition: var(--transition);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.5rem;
    color: #9ca3af;
    text-decoration: none;
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
    transition: var(--transition);
    cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Sidebar Hierarchy */
.nav-group {
    margin-bottom: 0.25rem;
}

.nav-link-parent {
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.nav-link-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 0 0 0.5rem 0.5rem;
}

.nav-children.expanded {
    max-height: 500px;
    /* Arbitrary large height for transition */
    transition: max-height 0.5s ease-in;
}

.nav-link-child {
    padding-left: 3rem;
    /* Indent children */
    font-size: 0.9rem;
    /* Smaller font size */
    margin-bottom: 0;
    border-radius: 0;
}

.nav-link-child:first-child {
    margin-top: 0.25rem;
}

.nav-link-child:last-child {
    margin-bottom: 0.25rem;
}

.chevron {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    /* Prevent shrinking */
}

.nav-link-parent.expanded .chevron {
    transform: rotate(180deg);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: var(--header-height);
    background-color: white;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    padding: 0 2rem;
    justify-content: space-between;
}

.page-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* Cards & UI Elements */
.card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    overflow: visible;
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

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

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

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

.btn-danger {
    background-color: #dc2626;
    color: white;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-input,
textarea.form-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    outline: none;
    font-family: inherit;
}

.form-input:focus,
textarea.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.table th {
    background-color: #f9fafb;
    font-weight: 600;
    color: #4b5563;
}

/* ===== Legacy Styles Port ===== */

/* Wrapper */
.wrapper {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
    width: 100%;
}

/* Grid System */
.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 12px;
}

.field {
    grid-column: span 4;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.span-2 {
    grid-column: span 6;
}

/* Select Edit (Autocomplete) */
.select-edit {
    position: relative;
    width: 100%;
}

.select-edit select {
    position: fixed;
    display: none;
    z-index: 9999;
    max-height: 280px;
    overflow: auto;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.select-edit select option {
    padding: 8px 12px;
    cursor: pointer;
}

.select-edit select option:hover {
    background-color: #f3f4f6;
}

/* Mix Table (FormulaÃ§Ã£o) */
.mix-wrap {
    grid-column: span 12;
    margin-top: 1rem;
}

.mix-title {
    font-weight: 800;
    margin: 6px 0;
    font-size: 1.1rem;
}

.mix-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.mix-table th {
    background: #f1f5f9;
    padding: 10px 12px;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.mix-table td {
    padding: 0;
    border-top: 1px solid #e5e7eb;
}

.mix-table input {
    width: 100%;
    height: 42px;
    border: none;
    padding: 0 12px;
    outline: none;
}

.mix-table input:focus {
    background-color: #f0f9ff;
}

.mix-table tbody tr.excede {
    background: #ffefef;
}

.mix-table tbody tr.excede .pct,
.mix-table tbody tr.excede .kg {
    outline: 2px solid #c62828;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 100;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.ok {
    background: #059669;
}

.toast.err {
    background: #dc2626;
}

.toast.warn {
    background: #d97706;
}

/* Utilities */
.ro {
    background-color: #f3f4f6;
    cursor: default;
}

.text-right {
    text-align: right;
}

.mt-4 {
    margin-top: 1rem;
}

.flex {
    display: flex;
}

.gap-2 {
    gap: 0.5rem;
}

.justify-end {
    justify-content: flex-end;
}

.w-full {
    width: 100%;
}

.error {
    border-color: #dc2626 !important;
}

.toolbar {}

/* ===== Legacy Styles Port ===== */

/* Wrapper */
.wrapper {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
    width: 100%;
}

/* Grid System */
.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 12px;
}

.field {
    grid-column: span 4;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.span-2 {
    grid-column: span 6;
}

/* Select Edit (Autocomplete) */
.select-edit {
    position: relative;
    width: 100%;
}

.select-edit select {
    position: fixed;
    display: none;
    z-index: 9999;
    max-height: 280px;
    overflow: auto;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.select-edit select option {
    padding: 8px 12px;
    cursor: pointer;
}

.select-edit select option:hover {
    background-color: #f3f4f6;
}

/* Mix Table (FormulaÃ§Ã£o) */
.mix-wrap {
    grid-column: span 12;
    margin-top: 1rem;
}

.mix-title {
    font-weight: 800;
    margin: 6px 0;
    font-size: 1.1rem;
}

.mix-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.mix-table th {
    background: #f1f5f9;
    padding: 10px 12px;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.mix-table td {
    padding: 0;
    border-top: 1px solid #e5e7eb;
}

.mix-table input {
    width: 100%;
    height: 42px;
    border: none;
    padding: 0 12px;
    outline: none;
}

.mix-table input:focus {
    background-color: #f0f9ff;
}

.mix-table tbody tr.excede {
    background: #ffefef;
}

.mix-table tbody tr.excede .pct,
.mix-table tbody tr.excede .kg {
    outline: 2px solid #c62828;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 100;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.ok {
    background: #059669;
}

.toast.err {
    background: #dc2626;
}

.toast.warn {
    background: #d97706;
}

/* Utilities */
.ro {
    background-color: #f3f4f6;
    cursor: default;
}

.text-right {
    text-align: right;
}

.mt-4 {
    margin-top: 1rem;
}

.flex {
    display: flex;
}

.gap-2 {
    gap: 0.5rem;
}

.justify-end {
    justify-content: flex-end;
}

.w-full {
    width: 100%;
}

.error {
    border-color: #dc2626 !important;
}

.toolbar {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 70px;
    }

    /* Sidebar Compact Mode */
    .nav-link span {
        display: none;
    }

    .nav-link {
        justify-content: center;
        padding: 0.75rem 0.25rem;
    }

    .logo {
        margin-bottom: 1rem;
        padding: 0.5rem 0;
    }

    .logo-icon {
        width: 40px;
        height: 40px;
    }

    /* Layout Adjustments */
    .page-container {
        padding: 1rem;
    }

    /* Toolbar & Buttons */
    .toolbar {
        flex-direction: column;
    }

    .toolbar .btn {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    /* Modal adjustments */
    .modal-content {
        width: 95%;
    }
}

/* Global Icon Fixes */
[data-lucide],
.lucide {
    user-select: none;
    /* Prevents text selection cursor */
}

/* Icons inside interactive elements should not capture pointer events */
button [data-lucide],
.btn [data-lucide],
.btn-icon [data-lucide],
.nav-link [data-lucide],
.nav-link-parent [data-lucide],
a [data-lucide] {
    pointer-events: none;
}

/* ========================================= */
/*           SETTINGS V2 (CLEAN LAYOUT)      */
/* ========================================= */

.settings-v2-page {
    max-width: 100%;
    padding-right: 2rem;
}

.settings-v2-title {
    font-size: 2rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 2rem;
}

.settings-v2-content {
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.settings-v2-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.settings-v2-subtitle {
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 1.5rem;
}

.settings-v2-grid {
    display: grid;
    grid-template-columns: 2fr 2fr 1.5fr 1.5fr 1fr;
    gap: 1rem;
    align-items: end;
}

.settings-v2-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.settings-v2-field label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #4b5563;
}

.settings-v2-field input,
.settings-v2-field select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.95rem;
    background-color: #fff;
}

.settings-v2-field input:focus,
.settings-v2-field select:focus {
    border-color: #2563eb;
    outline: none;
}

.btn-v2-create {
    background-color: #2563eb;
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    height: 38px;
}

.btn-v2-create:hover {
    background-color: #1d4ed8;
}

.settings-v2-divider {
    height: 1px;
    background-color: transparent;
    margin: 0;
}

.logo-v2-wrapper {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.logo-v2-dropzone {
    flex: 1;
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    background-color: #f9fafb;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: all 0.2s;
    min-height: 160px;
}

.drop-text {
    color: #6b7280;
    font-size: 0.9rem;
}

.btn-v2-upload {
    background-color: #374151;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
}

.btn-v2-upload:hover {
    background-color: #1f2937;
}

.logo-v2-preview {
    width: 160px;
    height: 160px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white;
    overflow: hidden;
}

.logo-v2-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.preview-placeholder {
    font-size: 2rem;
    font-weight: 700;
    color: #e5e7eb;
}

.settings-v2-help {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 0.75rem;
}

@media (max-width: 1024px) {
    .settings-v2-grid {
        grid-template-columns: 1fr 1fr;
    }

    .settings-v2-action {
        grid-column: span 2;
        text-align: right;
    }
}

@media (max-width: 768px) {
    .settings-v2-grid {
        grid-template-columns: 1fr;
    }

    .settings-v2-action {
        grid-column: span 1;
    }

    .logo-v2-wrapper {
        flex-direction: column;
    }

    .logo-v2-preview {
        width: 100%;
    }
}

/* Permissions Management Table */
.permissions-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
}

.permissions-table th,
.permissions-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.permissions-table th {
    background-color: #f9fafb;
    font-weight: 600;
    color: #4b5563;
    font-size: 0.875rem;
    text-transform: uppercase;
}

.permissions-table td {
    color: #374151;
    font-size: 0.95rem;
}

.permissions-table code {
    background-color: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    color: #1f2937;
}

.permissions-table .category-row {
    background-color: #f9fafb;
}

.permissions-table .category-row td {
    font-weight: 700;
    color: #1f2937;
    padding: 1rem;
}

.permissions-table input[type='checkbox'] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.text-danger {
    color: #dc2626;
}

.text-muted {
    color: #6b7280;
    font-style: italic;
}

/* Tab Styling */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Fix table spacing and layout */
.custom-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 1rem;
}

.custom-table thead {
    background-color: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
}

.custom-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #4b5563;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.custom-table td {
    padding: 1rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    color: #374151;
    font-size: 0.95rem;
}

.custom-table tbody tr:hover {
    background-color: #f9fafb;
}

.custom-table .badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.custom-table .badge-primary {
    background-color: #dbeafe;
    color: #1e40af;
}

.custom-table .badge-secondary {
    background-color: #e5e7eb;
    color: #4b5563;
}

.custom-table .status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.custom-table .status-dot.status-active {
    background-color: #10b981;
}

.custom-table .status-dot.status-inactive {
    background-color: #ef4444;
}

/* Role select dropdown in table */
.role-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #374151;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.role-select:hover {
    border-color: #9ca3af;
}

.role-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Delete button in table */
.btn-delete-user {
    padding: 0.5rem 1rem;
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-delete-user:hover {
    background-color: #dc2626;
}

.btn-delete-user:active {
    background-color: #b91c1c;
}

/* Badge for company owner */
.badge-owner {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    background-color: #fef3c7;
    color: #92400e;
    margin-left: 0.5rem;
}

/* Disabled role select */
.role-select:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Watermark */
.watermark {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 50;
    opacity: 0.6;
    pointer-events: none;
    user-select: none;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 6px 8px;
    border-radius: 6px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(0, 0, 0, 0.05);
    text-align: center;
}

.watermark-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.watermark-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.watermark-app-name {
    font-weight: 700;
    font-size: 0.55rem;
    color: #374151;
    line-height: 1.1;
}

.watermark-version {
    font-size: 0.45rem;
    color: #6b7280;
    line-height: 1.1;
}

/* ========================================= */
/*           OP CARD BUTTONS                 */
/* ========================================= */

.btn-finalize,
.btn-edit,
.btn-delete,
.btn-analise,
.btn-print {
    background: white;
    padding: 4px 8px;
    transition: all 0.2s;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
}

.btn-finalize {
    border: 1px solid #10b981;
    color: #10b981;
}

.btn-finalize:hover {
    background: #10b981;
    color: white;
}

.btn-edit {
    border: 1px solid #f97316;
    color: #f97316;
}

.btn-edit:hover {
    background: #f97316;
    color: white;
}

.btn-delete {
    border: 1px solid #ef4444;
    color: #ef4444;
}

.btn-delete:hover {
    background: #ef4444;
    color: white;
}

.btn-analise {
    border: 1px solid #2563eb;
    color: #2563eb;
}

.btn-analise:hover {
    background: #2563eb;
    color: white;
}

.btn-print {
    border: 1px solid #6b7280;
    color: #374151;
}

.btn-print:hover {
    background: #6b7280;
    color: white;
}