/* Warehouse Dashboard Styles */
:root {
    --primary-dark: #232323;
    --primary-light: #ffffff;
    --accent-gold: #04201f;
    --background-light-gray: #f0f2f5;
    --danger-red: #dc3545;
    --warning-yellow: #ffc107;
    --success-green: #28a745;
    --info-blue: #17a2b8;
    --border-color: #dee2e6;
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* Login Page Styles */
.login-page-body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--background-light-gray);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    background-color: var(--primary-light);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo {
    max-width: 200px;
    margin-bottom: 20px;
}

.login-container h1 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--primary-dark);
}

.login-container p {
    margin-bottom: 25px;
    color: #6c757d;
}

.login-form .form-group {
    text-align: left;
    margin-bottom: 20px;
}

.login-form .btn-primary {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 10px;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
}

body.dashboard-mode {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--background-light-gray);
    margin: 0;
    color: #333;
    font-size: 0.82rem; /* Final reduction for a very compact UI */
}

.dashboard-header {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    padding: 0.75rem 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1280px; /* Further reduced width for a more focused view */
    margin: 0 auto;
}

.dashboard-header .logo img {
    max-height: 40px;
    display: block;
}

.header-nav {
    display: flex;
    gap: 25px;
}

.nav-link {
    text-decoration: none;
    color: var(--primary-dark);
    font-weight: 500;
    font-size: 1rem;
    transition: color 0.2s ease;
}

.dashboard-header h1 {
    font-size: 1.5rem;
    margin: 0;
}

.nav-link:hover {
    color: var(--accent-gold);
}

.logout-link {
    text-decoration: none;
    color: #6c757d;
    font-weight: 500;
}

.dashboard-main {
    padding: 2rem;
}

/* Quick Add Form */
.add-order-container {
    background-color: var(--primary-light);
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.07);
}

.add-order-header {
    padding: 15px 25px;
    background-color: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.add-order-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--primary-dark);
}

.add-order-header .toggle-icon {
    transition: transform 0.3s ease;
}

.add-order-form {
    padding: 25px;
}

.add-order-container.open .add-order-form {
    /* This container is now always open on the edit page, no special styles needed */
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    margin-bottom: 15px;
    position: relative; /* Ensure context for absolute positioning */
    overflow: visible !important; /* Prevent clipping of dropdowns and validation messages */
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
    font-size: 0.8rem; /* Harmonized label size */
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px; /* Reduced padding */
    font-size: 0.82rem; /* Harmonized font size */
    border: 1px solid var(--border-color);
    border-radius: 5px;
}

.form-group input:read-only {
    background-color: #e9ecef;
    cursor: not-allowed;
}

.form-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    align-items: center;
}

.btn-primary {
    background-color: var(--accent-gold);
    color: var(--primary-light);
    padding: 9px 20px; /* Harmonized with btn-cancel */
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.8rem; /* Final reduction */
    transition: opacity 0.2s ease;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-danger {
    background-color: var(--danger-red);
    color: var(--primary-light);
    padding: 7px 16px; /* Harmonized padding */
    border: none;
    border-radius: 5px;
    font-weight: 500;
    cursor: pointer;
    font-size: 0.8rem; /* Harmonized font size */
    transition: opacity 0.2s ease;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); /* Smooth easing */
}

.btn-danger.confirm-mode {
    background-color: #8b0000; /* Deep warning red */
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.btn-cancel {
    display: inline-block;
    padding: 9px 20px; /* Harmonized padding */
    background-color: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.8rem; /* Harmonized font size */
    transition: background-color 0.2s ease;
}

.btn-cancel:hover {
    background-color: #dee2e6;
}

.btn-secondary:hover {
    opacity: 0.9;
}
/* Metrics Bar */
.metrics-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.metric-card {
    background-color: var(--primary-light);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.07);
    text-align: center;
    border-bottom: 5px solid;
}
.metric-card.picking { border-color: var(--warning-yellow); }
.metric-card.ready { border-color: var(--success-green); }
.metric-card.today { border-color: var(--info-blue); }

.metric-card h3 {
    font-size: 1.2rem;
    color: #6c757d;
    text-transform: uppercase;
    margin: 0 0 10px 0;
}

.metric-card .metric-value {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
}
.metric-card.picking .metric-value { color: var(--warning-yellow); }
.metric-card.ready .metric-value { color: var(--success-green); }
.metric-card.today .metric-value { color: var(--info-blue); }

/* Main Table */
.table-card {
    background-color: var(--primary-light);
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.07);
    overflow: hidden;
}

.dispatch-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem; /* Further reduced table font size */
}

.dispatch-table th, .dispatch-table td {
    padding: 10px 14px; /* Further reduced padding */
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.dispatch-table thead th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
    font-size: 0.78rem; /* Final reduction */
}
.dispatch-table thead th a {
    position: sticky; /* Ensure headers stay visible while scrolling */
    top: 0;
    z-index: 10;
    display: block;
}
.dispatch-table thead th a {
    text-decoration: none;
    color: inherit;
}
.dispatch-table thead th .fa-sort-up, .dispatch-table thead th .fa-sort-down {
    margin-left: 5px;
}

.dispatch-table tbody tr.entrega-armazem {
    background-color: #eef7ff; /* Light blue for warehouse pickups */
}

.priority-icon {
    color: var(--danger-red);
    font-size: 1.5rem;
}

.dispatch-table td.overdue {
    color: var(--danger-red);
    font-weight: 700;
}

.dispatch-table .order-row > td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dispatch-table .order-row > td.status-cell {
    overflow: visible; /* Override to prevent clipping the status dropdown */
}

/* Resizable Columns */
.dispatch-table.resizable {
    table-layout: fixed; /* Crucial for resizing */
}
.dispatch-table.resizable th {
    position: relative;
}
.resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    z-index: 10;
}

/* Admin Page Specifics */
.admin-content-container {
    max-width: 900px;
    margin: 0 auto;
}

.admin-content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.admin-content-header h2 {
    margin: 0;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    padding: 7px 16px; /* Harmonized padding */
    text-decoration: none;
    border-radius: 5px;
    font-weight: 500;
    font-size: 0.8rem; /* Harmonized font size */
}

.status-message {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
}
.status-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.actions {
    text-align: right;
}

.action-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--primary-dark);
    margin-left: 8px;
    transition: all 0.2s ease;
}
.action-icon-btn.edit {
    background-color: #e0f7fa;
    color: #00796b;
}
.action-icon-btn.delete {
    background-color: #ffebee;
    color: #c62828;
}

.document-links {
    display: flex;
    gap: 10px;
    align-items: center; /* Vertically center the icons */
}

.doc-link {
    font-size: 1.5rem;
    color: #6c757d;
    text-decoration: none;
    transition: color 0.2s ease;
}

.doc-link:hover {
    color: var(--accent-gold);
}

.file-upload-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    background-color: #f8f9fa;
}

.current-file {
    font-size: 0.9rem;
    color: #6c757d;
    margin-top: 8px;
}
.current-file a {
    color: var(--info-blue);
    font-weight: 500;
}

/* Filter Card */
.filter-card {
    background-color: var(--primary-light);
    padding: 20px; /* Reduced padding */
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.07);
    overflow: visible;
}

.filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px; /* Reduced gap */
    align-items: flex-end;
}

.filter-form .form-group {
    margin-bottom: 0;
}

.filter-form .form-group label {
    font-size: 0.7rem; /* Make labels even smaller */
    margin-bottom: 3px;
}

.filter-form .form-group input,
.filter-form .form-group select,
.filter-form .choices__inner {
    height: 28px; /* Force a smaller, consistent height */
    padding: 0 8px; /* Adjust horizontal padding */
    font-size: 0.75rem; /* Smaller font for filter inputs */
    min-height: auto; /* Override choices.js default */
    display: flex;
    align-items: center;
}

.filter-actions .btn-secondary,
.filter-actions .btn-primary {
    height: 28px; /* Match input height */
    padding: 0 12px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

/* --- Responsive Design --- */

@media (max-width: 992px) {


    /* Make the two-column form on edit_order.php stack vertically */
    .form-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-main {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    body.dashboard-mode {
        font-size: 1rem; /* Adjust base font size for smaller screens */
    }

    .dashboard-header h1 {
        font-size: 1.2rem;
    }

    /* Responsive tables for both admin list and dispatch dashboard */
    .dispatch-table thead,
    .admin-table thead {
        display: none; /* Hide table headers on mobile */
    }

    .dispatch-table .order-row,
    .admin-table tr {
        display: block;
        margin-bottom: 1.5rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        overflow: hidden;
        box-shadow: none;
    }
    
    .dispatch-table .order-details-row {
        box-shadow: none;
        margin-bottom: 0;
        border-radius: 0;
        background: transparent;
    }

    .dispatch-table .order-row td,
    .admin-table td {
        display: block;
        text-align: right; /* Value on the right */
        font-size: 1rem;
        border-bottom: 1px solid #eee;
        padding-left: 50%; /* Make space for the label */
        position: relative;
    }

    .dispatch-table .order-row td::before,
    .admin-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 18px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left; /* Label on the left */
        font-weight: 600;
        color: #333;
    }

    .dispatch-table .order-row td:last-child,
    .admin-table td:last-child {
        border-bottom: 0;
    }

    .filter-form {
        grid-template-columns: 1fr;
    }
    
    .order-details-grid {
        grid-template-columns: 1fr;
    }

    .order-details-layout {
        grid-template-columns: 1fr;
    }
}

.current-file-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    padding: 8px 12px;
    border-radius: 5px;
    margin-top: 10px;
    border: 1px solid var(--border-color);
}

.current-file-container .current-file {
    margin: 0;
}

.remove-file-container {
    font-size: 0.9rem;
}

.remove-file-container label {
    color: var(--danger-red);
    cursor: pointer;
    font-weight: 500;
}

.form-hint {
    font-size: 0.9rem;
    color: #6c757d;
    margin-top: 5px;
}

.admin-content-container.full-width {
    max-width: 1280px; /* Further reduced width for a more focused view */
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr; /* 60% table, 40% map */
    gap: 2rem;
}

.table-container {
    /* Default behavior */
}

.table-card {
    /* Default behavior */
}

.map-container {
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    top: 100px; /* Adjust based on header height */
    height: calc(100vh - 140px);
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.07);
    z-index: 1;
}


@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .map-container {
        position: relative;
        top: 0;
        height: 500px;
        margin-top: 2rem;
    }
}

.edit-map-container {
    width: 100%;
    height: 300px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    z-index: 1;
    overflow: hidden; /* Force map tiles to stay within the container bounds */
}

.address-search-wrapper {
    position: relative;
}

/* Address Search Results */
#address-results-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1001;
}

.address-results {
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 5px 5px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.address-result-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}
.address-result-item.no-results {
    color: #6c757d;
    cursor: default;
}

.address-result-item:hover:not(.no-results) {
    background-color: #e0f7fa; /* A light teal for better visibility */
    color: #00796b; /* Darker text for contrast */
}

/* Geosearch input styling */
.leaflet-control-geosearch {
    font-family: 'Montserrat', sans-serif;
}
.geosearch .glass {
    border-radius: 5px 0 0 5px;
    border: 1px solid var(--border-color);
    border-right: none;
}
.geosearch .results {
    border-radius: 5px;
    margin-top: 5px;
    z-index: 10001; /* This is the correct fix to ensure results are on top */
}
.geosearch form input {
    font-size: 1rem !important;
    padding: 12px 15px !important;
    border-radius: 0 5px 5px 0;
    border: 1px solid var(--border-color);
}
.geosearch form input:focus {
    border-color: var(--accent-gold);
}
.geosearch a.active, .geosearch .results > .active {
    background-color: var(--accent-gold);
    color: white;
}

/* Form Label Group for side-by-side button */
.form-label-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.btn-link-small {
    background: none;
    border: none;
    color: var(--info-blue);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
}
.btn-link-small:hover {
    text-decoration: underline;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background-color: var(--primary-light);
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 500px;
    animation: slide-down 0.3s ease-out;
}

@keyframes slide-down {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s ease;
}
.modal-close-btn:hover {
    color: var(--primary-dark);
}

.modal-body {
    padding: 25px;
}

.modal-body .status-message {
    margin-top: 15px;
    margin-bottom: 0;
}

/* Ensure Leaflet Geosearch results are visible and on top */
.leaflet-control-geosearch.geosearch-bar {
    z-index: 10000; /* Ensure the search control is on top */
    position: relative; /* Establish a new stacking context for its children */
}
.geosearch-results {
    z-index: 10001; /* Ensure the results dropdown is on top of everything */
}
/* Expandable Row Styles */
.order-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.order-row:not(.priority-high):hover {
    background-color: #f8f9fa;
}

.order-row.active {
    background-color: #f8f9fa; /* Match details background for seamless look */
    border-bottom-color: transparent; /* Hide border when expanded */
}

.order-row.highlight-row {
    background-color: #ffeeba !important; /* Highlight color (yellowish) */
    transition: background-color 0.5s ease;
}

.new-order-highlight {
    background-color: #ffeeba !important; /* Yellowish for new orders */
    transition: background-color 2s ease-out;
}

.order-details-row {
    display: none;
}

.order-details-row.visible {
    display: table-row;
}

/* Mobile optimizations for expandable rows */
@media (max-width: 768px) {
    .dispatch-table .order-row.active {
        border-bottom: none;
        border-radius: 8px 8px 0 0;
        margin-bottom: 0;
        background-color: #f8f9fa;
    }

    .dispatch-table .order-details-row.visible {
        display: block;
        border: 1px solid var(--border-color);
        border-top: none;
        border-radius: 0 0 8px 8px;
        margin-bottom: 1.5rem;
        background-color: #f8f9fa;
    }
    
    .dispatch-table .order-details-row td {
        display: block;
        width: 100%;
        padding: 0;
    }
}

.order-details-row > td {
    padding: 0; /* Remove padding from the container cell to collapse the separator */
}

.order-details-content {
    padding: 10px 15px;
    background-color: #f8f9fa;
}

.order-details-layout {
    display: grid;
    grid-template-columns: 1.5fr 1fr; /* 60% / 40% split */
    gap: 20px;
    margin-bottom: 15px;
}

.details-col-left, .details-col-right {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.details-divider {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--border-color);
    margin: 5px 0;
}

.details-label {
    color: #6c757d;
    font-size: 0.75rem;
    font-weight: bold;
    display: block;
    margin-bottom: 3px;
}

.details-secondary-group {
    gap: 10px; /* Tighter spacing for secondary items */
    font-size: 0.8rem;
}

.details-secondary-group > div {
    line-height: 1.5;
}

.details-secondary-group strong,
.details-block strong {
    display: block;
    color: #6c757d;
    font-size: 0.75rem; /* Make labels slightly smaller than content */
    margin-bottom: 2px;
}

.details-actions, .details-docs {
    grid-column: 1 / -1;
}

.details-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.details-block {
    margin-bottom: 0; /* Handled by flex gap */
}

.details-block p {
    margin: 0;
}

.text-large {
    font-size: 1rem;
    color: inherit;
}

.highlight-discount {
    color: var(--success-green);
    font-weight: bold;
}

/* Choices.js Overrides for a compact UI */
.filter-form .choices__inner .choices__list--single .choices__item {
    font-size: 0.75rem; /* Match other filter inputs */
}

/* Ensure the container is the positioning context */
.filter-form .choices {
    position: relative;
}

/* Global Choices.js fixes for overflow and z-index */
.choices {
    overflow: visible;
}

/* This styles the dropdown container itself */
.filter-form .choices__list--dropdown {
    font-size: 0.7rem; /* Set base font for all dropdown items */
    top: 100% !important; /* Force alignment to bottom of input */
    margin-top: 0 !important; /* Remove any gap */
    left: 0 !important; /* Align to left edge */
    width: 100% !important; /* Match width of container */
}

/* This styles the individual search result items in the dropdown */
.filter-form .choices__list--dropdown .choices__item--selectable {
    padding: 6px 8px;
}

/* This styles the individual search result items in the dropdown */
.filter-form .choices__list--dropdown .choices__notice {
    padding: 6px 8px;
    color: #888;
}

/* Fix Z-Index for Choices.js to float above table headers */
.choices__list--dropdown, .choices__list[aria-expanded] {
    z-index: 10000 !important;
    position: absolute !important; /* Ensure it breaks out of the flow */
}

/* Fix for Resumo dos Artigos Textarea */
#items_summary {
    resize: none; /* Disable manual resizing */
    height: 220px; /* Fixed height for ~10 lines visibility */
    width: 100%; /* Ensure it stays within container */
    margin-bottom: 10px; /* Spacing before next fields */
}

.priority-high-text {
    color: var(--danger-red);
    font-weight: bold;
}

/* Disable resizing for Comments Textarea */
#comments {
    resize: none;
}

.status-cell {
    position: relative;
}

.status-select {
    width: 100%;
    padding: 6px 10px; /* Increased padding for better readability */
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: #f8f9fa;
    font-weight: 500;
    font-size: 0.8rem; /* Match table font size */
    cursor: pointer;
}

.status-select.status-pendente {
    background-color: #c9def2; /* Light Cyan/Blue */
    color: #006064;
    border-color: #b2ebf2;
}
.status-select.status-pronto {
    background-color: #bff0c2; /* Light Green */
    color: #155724;
    border-color: #c3e6cb;
}
.status-select.status-entregue {
    background-color: #e2e3e5; /* Light Gray */
    color: #383d41;
    border-color: #d6d8db;
}

/* Ensure dropdown options have a neutral background */
.status-select option {
    background-color: #f8f9fa;
    color: #333;
}

.status-update-feedback {
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
}
.status-update-feedback.success {
    color: var(--success-green);
}
.status-update-feedback.error {
    color: var(--danger-red);
}

/* Admin Page Specifics */
.admin-content-container {
    max-width: 900px;
    margin: 0 auto;
}

.admin-content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.admin-content-header h2 {
    margin: 0;
    font-size: 1.3rem; /* Final reduction */
}

/* Map Marker Customizations */
.map-marker-container {
    position: relative;
    width: 25px;
    height: 41px;
}
.map-marker-img {
    width: 25px;
    height: 41px;
    display: block;
}
.map-marker-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background-color: var(--danger-red);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 1000;
}

/* Custom Warehouse Pin Style */
.warehouse-pin {
    background-color: var(--primary-dark);
    color: var(--warning-yellow);
    width: 40px;
    height: 40px;
    border-radius: 50% 50% 50% 0; /* Teardrop shape */
    transform: rotate(-45deg); /* Rotate to point down */
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
.warehouse-pin i {
    transform: rotate(45deg); /* Rotate icon back to be upright */
    font-size: 16px;
}

.map-label {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 10px;
    font-weight: 600;
    color: #333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    white-space: nowrap;
}

.warning-icon {
    color: var(--warning-yellow);
    margin-left: 6px;
    font-size: 0.9em;
}

.credit-limit-info {
    color: #6c757d;
    font-size: 0.85rem;
}

/* Custom UI Validation Styles */
.is-invalid {
    border-color: var(--danger-red, #dc3545) !important;
    background-color: #fff8f8 !important;
}

.choices__inner.is-invalid {
    border-color: var(--danger-red, #dc3545) !important;
    background-color: #fff8f8 !important;
}

.invalid-feedback {
    color: var(--danger-red, #dc3545);
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    gap: 10px;
    border-top: 1px solid var(--border-color);
}
.pagination a, .pagination span.current {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-decoration: none;
    color: var(--primary-dark);
    font-size: 0.85rem;
}
.pagination a:hover {
    background-color: #f8f9fa;
}
.pagination span.current {
    background-color: var(--accent-gold);
    color: white;
    border-color: var(--accent-gold);
}

/* Mobile adjustments for form actions */
@media (max-width: 576px) {
    .form-actions {
        flex-direction: column;
    }
    .form-actions a, .form-actions button {
        width: 100%;
        margin-bottom: 10px;
        margin-right: 0 !important;
        text-align: center;
        justify-content: center;
    }
}

/* --- PREMIUM SETTINGS ROW (INLINE CONTROL CARD) --- */
.premium-settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8fafc; /* Very soft, premium SaaS gray */
    border: 1px solid #e2e8f0; /* Subtle defining border */
    border-radius: 8px; /* Modern rounded corners */
    padding: 12px 16px; /* Tight, balanced padding */
    margin-bottom: 24px; /* Space before the actual form fields start */
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.settings-row-label {
    display: flex;
    flex-direction: column;
}

.settings-row-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--brand-dark, #04201f);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-row-desc {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 2px;
}

/* The iOS-style toggle - Scaled down for spatial efficiency */
.modern-toggle {
    position: relative;
    display: inline-block;
    width: 40px;  /* Shrunk */
    height: 20px; /* Shrunk */
}

.modern-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .3s cubic-bezier(0.165, 0.84, 0.44, 1);
    border-radius: 20px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px; /* Shrunk */
    width: 16px;  /* Shrunk */
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s cubic-bezier(0.165, 0.84, 0.44, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.modern-toggle input:checked + .toggle-slider {
    background-color: #0f5c59; /* Brand Teal */
}

.modern-toggle input:checked + .toggle-slider:before {
    transform: translateX(20px); /* Adjusted for new width */
}

/* Clean up default Google Maps InfoWindow padding & styling */
.gm-style-iw-c {
    padding: 12px 10px 16px 16px !important; /* Tighter top/right padding */
    border-radius: 12px !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15) !important;
}
.gm-style-iw-d {
    overflow: hidden !important; /* Hide scrollbars if content is short */
}

/* Fix for giant Google Maps InfoWindow Close Button */
.gm-ui-hover-effect {
    top: 6px !important;
    right: 6px !important;
    width: 24px !important;
    height: 24px !important;
    background-color: #f8f9fa !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 1 !important;
    transition: background-color 0.2s ease !important;
}
.gm-ui-hover-effect:hover {
    background-color: #e2e6ea !important;
}
.gm-ui-hover-effect span, .gm-ui-hover-effect img {
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
    pointer-events: none; /* Prevent click target issues */
}

.map-popup-container {
    max-width: 320px;
    font-family: 'Montserrat', sans-serif;
    color: #333;
    padding-right: 28px; /* Safely clear the absolute-positioned close button */
}
.map-popup-order {
    padding: 12px 0;
    border-bottom: 1px solid #eaeaea;
}
.map-popup-order:first-child {
    padding-top: 0;
}
.map-popup-order:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.map-popup-client {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 5px;
    line-height: 1.2;
}
.map-popup-address {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.3;
}
.map-popup-address i {
    margin-top: 2px;
    color: var(--accent-gold);
}
.map-popup-items {
    font-size: 0.75rem;
    color: #555;
    background-color: #f8f9fa;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    max-height: 100px;
    overflow-y: auto;
}

/* New Order Notification Toast */
.new-orders-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px); /* Start hidden below screen */
    background-color: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 9999;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.new-orders-notification.show {
    transform: translateX(-50%) translateY(0);
}

.new-orders-notification .notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.new-orders-notification .btn-refresh {
    background-color: var(--accent-gold);
    color: white;
    border: none;
    padding: 6px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.8rem;
    transition: background-color 0.2s;
}

.new-orders-notification .btn-refresh:hover {
    background-color: #031615; /* Darker gold */
}

/* --- Global Drawer Styles --- */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1040;
}

.order-drawer {
    position: fixed;
    top: 15px;
    bottom: 15px;
    right: -800px; /* Hidden state */
    width: 800px;
    max-width: calc(100% - 30px);
    height: calc(100vh - 30px);
    background-color: #f4f5f7; /* Light gray interior */
    border-radius: 16px;
    box-shadow: -10px 10px 40px rgba(0,0,0,0.12);
    border: 1px solid rgba(255,255,255,0.5);
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1); /* Apple-like spring */
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.order-drawer.drawer-wide {
    width: 750px;
    right: -750px;
    max-width: calc(100% - 30px);
}

.drawer-open .drawer-overlay {
    opacity: 1;
    pointer-events: auto;
}

.drawer-open .order-drawer {
    right: 15px; /* Floating margin */
}

.drawer-header {
    background: #ffffff;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.drawer-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 0;
    letter-spacing: -0.02em;
}

.drawer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
#drawer-title {
    flex: 1;
    min-width: 0; 
    padding: 0 5px; 
}

.drawer-actions,
#btn-close-drawer,
#drawer-save-btn {
    flex-shrink: 0;
}

.btn-icon-action {
    background: #f1f3f5;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon-action:hover {
    background: #e9ecef;
    color: var(--primary-dark);
}

.btn-icon-action.close-drawer:hover {
    color: #dc3545;
    transform: rotate(90deg);
}

#drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    position: relative;
}

/* Custom Scrollbar for Drawer */
#drawer-content::-webkit-scrollbar {
    width: 6px;
}
#drawer-content::-webkit-scrollbar-track {
    background: transparent;
}
#drawer-content::-webkit-scrollbar-thumb {
    background-color: #ced4da;
    border-radius: 20px;
}

.details-actions {
    margin-top: 20px;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 15px;
}

.details-actions a, .details-actions button {
    width: auto !important;
    flex: 0 1 auto !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px; /* Perfect spacing between icon and text */
    font-family: inherit; /* Forces buttons to use Montserrat */
    font-size: 0.8rem;
    height: 34px; /* Mathematically forces exact same height */
    padding: 0 16px;
    box-sizing: border-box;
    margin: 0;
    line-height: 1; /* Prevents text shifting */
}

/* --- Context-Aware Drawer Overrides --- */
/* Forces the grid layout to stack vertically when inside the drawer */
#drawer-content .order-details-layout {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#drawer-content .details-col-left, 
#drawer-content .details-col-right {
    padding: 0;
    box-shadow: none;
    border: none;
}

/* Premium Dispatch Button */
.btn-dispatch-inline {
    background: transparent;
    border: none;
    color: #6c757d;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    font-weight: bold;
    overflow: hidden;
    white-space: nowrap;
    margin-left: auto; /* Push to the right */
    margin-right: 5px;
}
.btn-dispatch-inline:hover { color: var(--primary-dark); background: #e9ecef; }
.btn-dispatch-inline.confirm-mode { 
    background: var(--success-green); 
    color: white; 
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
    border-color: var(--success-green);
}
.btn-dispatch-inline i { font-size: 1rem; }

@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Drawer Header Save Button - Minimalist */
#drawer-save-btn {
    color: var(--success-green);
    background-color: #e8f5e9;
}
#drawer-save-btn:hover {
    background-color: var(--success-green);
    color: white;
}

/* Hide default form submit button in drawer */
#drawer-content form button[type="submit"] {
    display: none !important;
}

/* --- Workload / Kanban Styles --- */
.workload-section { margin-bottom: 40px; }

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 15px;
    padding-left: 5px;
    border-left: 4px solid var(--accent-gold);
    line-height: 1.2;
}

.workload-grid {
    display: grid;
    gap: 15px;
    width: 100%;
    align-items: start;
}
.workload-grid.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.workload-grid.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.kanban-column {
    background-color: #f8f9fa;
    border-radius: 6px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    min-height: 250px; 
    border: 1px solid transparent; 
}

.kanban-column.today {
    background-color: #ffffff;
    border-top: 3px solid var(--accent-gold);
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}

.overdue-section {
    background-color: #fff3cd;
    border: 1px solid #f5c6cb; 
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.overdue-header {
    font-weight: 700;
    color: #856404;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    font-size: 1.1rem;
}

.kanban-header {
    padding: 8px 5px;
    margin-bottom: 12px;
    border-bottom: 2px solid rgba(0,0,0,0.03);
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--primary-dark);
    font-size: 0.9rem;
    position: sticky;
    top: 0;
}

.kanban-header .badge {
    background-color: rgba(0,0,0,0.06);
    color: #555;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 700;
}

.kanban-body {
    flex-grow: 1;
    min-height: 150px; 
}

.overdue-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.kanban-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    cursor: grab;
    transition: all 0.2s ease;
    position: relative;
    min-width: 0; 
}

.overdue-container .kanban-card { width: 280px; }

.kanban-card:hover {
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
    transform: translateY(-3px);
    border-color: #ccc;
}

.kanban-card:active { cursor: grabbing; }

.kanban-card.priority-high { border-left: 4px solid var(--danger-red); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.card-id {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary-dark);
}

.card-client {
    font-size: 0.8rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    position: relative; 
    min-height: 32px; 
}

.status-badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 50px; 
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.pendente { background-color: #e3f2fd; color: #006064; }
.status-badge.pronto { background-color: #e8f5e9; color: #155724; }
.delivery-icon { color: #adb5bd; font-size: 0.85rem; }

.btn-toggle-status {
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #adb5bd;
    transition: all 0.2s;
}

.btn-toggle-status:hover {
    border-color: var(--success-green);
    color: var(--success-green);
    background-color: #f0fff4;
}

.btn-toggle-status.is-pronto {
    background-color: var(--success-green);
    border-color: var(--success-green);
    color: white;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s;
}
.toast.show { opacity: 1; }

@media (max-width: 1400px) {
    .workload-grid.grid-6 { grid-template-columns: 200px repeat(5, 1fr); }
    .workload-grid.grid-5 { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 1200px) {
    .workload-grid {
        overflow-x: auto;
        min-width: 100%;
        padding-bottom: 15px;
    }
    .admin-content-container { overflow-x: hidden; }
}