@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --color-sage: #84A98C;
    --color-sage-light: #cad2c5;
    --color-slate: #52796F;
    --color-slate-dark: #354f52;
    --color-slate-light: #84a98c22;
    --color-background: #F8F9FA;
    --color-card-bg: #FFFFFF;
    --color-alert: #E56B6F;
    --color-alert-light: #ffeaec;
    --color-text-dark: #212529;
    --color-text-muted: #6c757d;
    --color-border: #E9ECEF;
    --border-radius: 12px;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    --box-shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.06);
    --transition-speed: 0.25s;
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--color-background);
    color: var(--color-text-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Base Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Typography & Links */
h1,
h2,
h3,
h4 {
    color: var(--color-slate-dark);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

p {
    color: var(--color-text-muted);
}

a {
    color: var(--color-slate);
    text-decoration: none;
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--color-slate-dark);
}

/* Sidebar - Desktop */
.sidebar {
    width: 260px;
    background-color: var(--color-slate-dark);
    color: #FFFFFF;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
}

.sidebar-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-sage-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    list-style: none;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    color: #cad2c5;
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: all var(--transition-speed);
}

.sidebar-link:hover,
.sidebar-link.active {
    background-color: var(--color-slate);
    color: #FFFFFF;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1.5rem;
}

/* Bottom Bar - Mobile */
.bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background-color: var(--color-slate-dark);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 1000;
}

.bottom-menu {
    display: flex;
    height: 100%;
    list-style: none;
}

.bottom-item {
    flex: 1;
}

.bottom-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #cad2c5;
    font-size: 0.8rem;
    transition: color var(--transition-speed);
}

.bottom-link.active,
.bottom-link:hover {
    color: #FFFFFF;
    background-color: var(--color-slate);
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        padding-bottom: 64px;
    }

    .sidebar {
        display: none;
    }

    .bottom-bar {
        display: block;
    }

    .main-content {
        padding: 1rem;
    }
}

/* Navbar */
.top-navbar {
    background-color: var(--color-card-bg);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

/* Cards & Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background-color: var(--color-card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--box-shadow);
    border: 1px solid var(--color-border);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--box-shadow-hover);
}

.card-alert {
    border-color: var(--color-alert);
    background-color: var(--color-alert-light);
}

.card-alert h3 {
    color: var(--color-alert);
}

.card-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--color-slate-dark);
}

.card-alert .card-value {
    color: var(--color-alert);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    background-color: var(--color-card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--color-border);
    margin-bottom: 2rem;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.custom-table th {
    background-color: #F1F3F5;
    color: var(--color-slate-dark);
    padding: 1rem;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 2px solid var(--color-border);
}

.custom-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.95rem;
}

.custom-table tbody tr {
    transition: background-color var(--transition-speed);
}

.custom-table tbody tr:hover {
    background-color: var(--color-slate-light);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-pending {
    background-color: #FFEED9;
    color: #FD7E14;
}

.badge-delivered {
    background-color: #E2F0D9;
    color: #388E3C;
}

.badge-alert {
    background-color: var(--color-alert-light);
    color: var(--color-alert);
}

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

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--color-slate-dark);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    font-family: inherit;
    font-size: 1rem;
    background-color: var(--color-background);
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-slate);
    box-shadow: 0 0 0 3px rgba(82, 121, 111, 0.15);
    background-color: #FFFFFF;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    transition: all var(--transition-speed);
}

.btn-primary {
    background-color: var(--color-slate);
    color: #FFFFFF;
}

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

.btn-danger {
    background-color: var(--color-alert);
    color: #FFFFFF;
}

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

.btn-outline {
    background-color: transparent;
    border: 1.5px solid var(--color-slate);
    color: var(--color-slate);
}

.btn-outline:hover {
    background-color: var(--color-slate);
    color: #FFFFFF;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    width: 100%;
}

.segmented-control {
    display: flex;
    background-color: var(--color-border);
    border-radius: var(--border-radius);
    padding: 3px;
    margin-bottom: 1.25rem;
}

.segmented-option {
    flex: 1;
    text-align: center;
    position: relative;
}

.segmented-option input[type="radio"] {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.segmented-label {
    display: block;
    padding: 0.8rem 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-text-muted);
    border-radius: calc(var(--border-radius) - 3px);
    transition: all var(--transition-speed);
    user-select: none;
}

.segmented-option input[type="radio"]:checked+.segmented-label {
    background-color: var(--color-slate);
    color: #FFFFFF;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* =========================================
   UI CLEAN: CAMERA MOBILE (ATUALIZADO FASE 10)
========================================= */

.camera-container {
    background-color: #000000;
    border-radius: var(--border-radius);
    position: relative;
    aspect-ratio: 4/3;
    max-height: 380px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.camera-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay,
.camera-scanline {
    display: none !important;
}

.camera-focus-guide {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    pointer-events: none !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
    padding-top: 2rem !important;
    box-sizing: border-box !important;
}

.ocr-result-log {
    background-color: #212529;
    color: #A3E635;
    font-family: monospace;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    white-space: pre-line;
}

/* Alerts */
.alert-container {
    margin-bottom: 1.5rem;
}

.alert-message {
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-success {
    background-color: #E2F0D9;
    color: #388E3C;
    border: 1px solid #C5E1B7;
}

.alert-danger {
    background-color: var(--color-alert-light);
    color: var(--color-alert);
    border: 1px solid #F5C6CB;
}

.alert-warning {
    background-color: #FFF3CD;
    color: #856404;
    border: 1px solid #FFEBAA;
}

/* Pages */
.self-service-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--color-background);
    padding: 1.5rem;
}

.self-service-card {
    width: 100%;
    max-width: 480px;
    background-color: var(--color-card-bg);
    border-radius: var(--border-radius);
    padding: 2.5rem 2rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--color-border);
}

.self-service-header {
    text-align: center;
    margin-bottom: 2rem;
}

.self-service-logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-slate-dark);
    margin-bottom: 0.5rem;
}

.search-container {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.dashboard-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-speed);
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
    pointer-events: all;
}

.modal-overlay .modal-content {
    background-color: var(--color-card-bg);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 400px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* Utilities */
.search-form-stacked {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.search-form-stacked .btn-search {
    align-self: flex-start;
}

@media (max-width: 768px) {
    .search-form-stacked .btn-search {
        width: 100%;
        align-self: stretch;
    }
}

.camera-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 99999 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: #000 !important;
    max-width: none !important;
    border-radius: 0 !important;
    aspect-ratio: auto !important;
}

.card.parent-fullscreen {
    transform: none !important;
    position: static !important;
    z-index: auto !important;
}

.camera-container,
.camera-container *,
#btn-toggle-camera,
#btn-switch-camera,
#btn-escanear,
#btn-fullscreen-camera {
    user-select: none !important;
    -webkit-user-select: none !important;
    touch-action: manipulation !important;
}

.card-touch-swipe {
    display: block;
    width: 100%;
    overflow-x: auto;
    touch-action: pan-x pan-y !important;
    -webkit-overflow-scrolling: touch;
    background-color: var(--color-card-bg);
}

.card-touch-swipe table {
    width: 100% !important;
    border-collapse: collapse;
}

.card-touch-swipe th,
.card-touch-swipe td {
    pointer-events: auto !important;
    background-clip: padding-box;
}