:root {
    --primary: #10B981; /* Emerald 500 */
    --primary-hover: #059669; /* Emerald 600 */
    --primary-light: #D1FAE5; /* Emerald 100 */
    
    --surface: #FFFFFF;
    --background: #F8FAFC; /* Slate 50 */
    --sidebar-bg: #0F172A; /* Slate 900 */
    --sidebar-text: #94A3B8; /* Slate 400 */
    --sidebar-active: #F8FAFC;
    
    --text-main: #0F172A;
    --text-muted: #64748B;
    
    --border: #E2E8F0; /* Slate 200 */
    
    /* Semantic */
    --blue: #3B82F6;
    --blue-light: #DBEAFE;
    --yellow: #F59E0B;
    --yellow-light: #FEF3C7;
    --green: #10B981;
    --green-light: #D1FAE5;
    --orange: #F97316;
    --purple: #8B5CF6;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    height: 72px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    color: #FFF;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header i {
    color: var(--primary);
    font-size: 24px;
}

.sidebar-nav {
    padding: 24px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link i {
    font-size: 20px;
}

.nav-link:hover {
    color: #FFF;
    background-color: rgba(255,255,255,0.05);
}

.nav-link.active {
    color: #FFF;
    background-color: var(--primary);
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.store-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #FFF;
    font-weight: 500;
}

.logout-link {
    margin: 0 -12px;
}
.logout-link:hover {
    color: #FCA5A5;
    background-color: rgba(239, 68, 68, 0.1);
}

.status-dot {
    width: 10px;
    height: 10px;
    background-color: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 72px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-main);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-main);
    cursor: pointer;
    margin-right: 16px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 90;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.date-display {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.content-area {
    padding: 32px;
    max-width: 1200px;
    width: 100%;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* UI Elements */
.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 18px;
    font-weight: 600;
}

.btn {
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-size: 14px;
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}
.btn-outline:hover, .btn-outline.active {
    border-color: var(--primary);
    color: var(--primary);
    background-color: var(--primary-light);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
}
.btn-icon:hover { color: var(--text-main); }

.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.badge-yellow { background-color: var(--yellow-light); color: #B45309; }
.badge-blue { background-color: var(--blue-light); color: #1D4ED8; }
.badge-green { background-color: var(--green-light); color: #047857; }

/* Dashboard Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.metric-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 12px;
}

.metric-header i { font-size: 24px; }

.metric-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.metric-trend {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}
.metric-trend.positive { color: var(--green); }
.metric-trend.neutral { color: var(--text-muted); }

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 24px;
}

.alert-box {
    background-color: var(--yellow-light);
    border: 1px solid #FDE68A;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.alert-icon i {
    font-size: 32px;
    color: var(--yellow);
}
.alert-content { flex: 1; }
.alert-content h3 { font-size: 16px; color: #92400E; margin-bottom: 4px; }
.alert-content p { font-size: 14px; color: #B45309; }

.order-list { list-style: none; }
.order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.order-item:last-child { border-bottom: none; }
.order-info { display: flex; align-items: center; gap: 12px; }
.order-id { font-weight: 700; }
.order-customer { color: var(--text-muted); }

.map-placeholder {
    height: 300px;
    background-color: #F1F5F9;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 12px;
}
.map-placeholder i { font-size: 48px; color: #CBD5E1; }

/* Table */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}
.search-input {
    position: relative;
    width: 320px;
}
.search-input i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.search-input input {
    width: 100%;
    padding: 10px 10px 10px 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
}
.search-input input:focus { border-color: var(--primary); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; }

.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    color: var(--text-muted);
    font-weight: 500;
}
.data-table tbody tr:hover {
    background-color: #F8FAFC;
}

/* Utilities */
.text-blue { color: var(--blue); }
.text-orange { color: var(--orange); }
.text-green { color: var(--green); }
.text-purple { color: var(--purple); }
.text-red { color: #EF4444; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.mt-1 { margin-top: 4px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.pt-4 { padding-top: 16px; }
.border-top { border-top: 1px solid var(--border); }
.max-w-2xl { max-width: 42rem; }
.d-block { display: block; }

/* Chart */
.chart-mockup {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    height: 200px;
}
.chart-mockup .bar {
    flex: 1;
    background-color: var(--blue-light);
    border-radius: 6px 6px 0 0;
    transition: all 0.3s;
}
.chart-mockup .bar.active, .chart-mockup .bar:hover {
    background-color: var(--blue);
}

/* Ranking */
.ranking-list { list-style: none;}
.ranking-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.ranking-driver {
    display: flex;
    align-items: center;
    gap: 16px;
}
.avatar-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #F1F5F9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-muted);
}
.rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    color: var(--yellow);
}

/* Forms */
.form-row {
    display: flex;
    gap: 24px;
}
.form-group {
    margin-bottom: 20px;
    flex: 1;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-muted);
}
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    color: var(--text-main);
    transition: all 0.2s;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.payment-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
}
.checkbox-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
}
.checkbox-option input { width: 16px; height: 16px; cursor: pointer; }

.badge[onclick] { cursor: pointer; }

@media(max-width: 1024px) {
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
}

/* Menu lateral retrátil em telas pequenas */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    .topbar {
        padding: 0 16px;
    }
    .topbar h1 {
        font-size: 17px;
    }
    .date-display {
        display: none;
    }
    .content-area {
        padding: 16px;
    }
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .search-input {
        width: 100%;
    }
    .data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* ===== Novo Pedido (PDV) ===== */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
    align-items: start;
}

.pos-products {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.product-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.product-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 4px;
}

.product-card h3 {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

.product-card .product-category {
    font-size: 12px;
    color: var(--text-muted);
}

.product-card .product-price {
    font-size: 18px;
    font-weight: 700;
    margin: 4px 0;
}

.btn-add {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Carrinho */
.pos-cart {
    position: sticky;
    top: 88px;
    display: flex;
    flex-direction: column;
}

.cart-items {
    max-height: 240px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }

.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 600; font-size: 13px; }
.cart-item-price { font-size: 12px; color: var(--text-muted); }

.qty-stepper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.qty-stepper button {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    line-height: 1;
    color: var(--text-main);
}
.qty-stepper button:hover { border-color: var(--primary); color: var(--primary); }
.qty-stepper span { min-width: 18px; text-align: center; font-weight: 600; }

.cart-summary {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cart-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-muted);
}
.cart-summary-row.total {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 4px;
}

/* Endereço de entrega preenchido a partir do cadastro do cliente */
.address-info-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--background);
}
.address-info-box i.ph-map-pin {
    font-size: 18px;
    color: var(--primary);
    margin-top: 2px;
    flex-shrink: 0;
}
.address-info-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}
.address-info-box .btn-icon {
    flex-shrink: 0;
}

/* Forma de pagamento */
.payment-methods {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.payment-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}
.payment-option i { font-size: 22px; color: var(--text-muted); }
.payment-option input { display: none; }
.payment-option:has(input:checked) {
    border-color: var(--primary);
    background-color: var(--primary-light);
    color: var(--primary-hover);
}
.payment-option:has(input:checked) i { color: var(--primary); }

.btn-block {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

@media (max-width: 1024px) {
    .pos-layout { grid-template-columns: 1fr; }
    .pos-cart { position: static; }
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background-color: var(--text-main);
    color: #FFF;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 1000;
}
.toast.show {
    transform: translateY(0);
    opacity: 1;
}
.toast i { font-size: 20px; color: var(--primary); }
.toast.toast-error i { color: #EF4444; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}
.modal {
    background-color: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.modal-row:last-child { border-bottom: none; }
.modal-row.total {
    font-size: 16px;
    font-weight: 700;
    border-top: 1px solid var(--border);
    border-bottom: none;
    margin-top: 8px;
    padding-top: 12px;
}
.modal-items {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.modal-items li {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.modal-items li:last-child { border-bottom: none; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}
