/* CSS Variables & Theme */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

button,
input,
textarea {
    font-family: inherit;
}

/* Layout */
.app-container {
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    /* Changed from space-between to center relative positioning */
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
}

.banner-img {
    height: 120px;
    width: auto;
    object-fit: contain;
    max-width: 100%;
}

/* Position settings buttons absolutely to kept logo centered */
.header-actions {
    position: absolute;
    right: 1.5rem;
    display: flex;
    gap: 0.5rem;
}

.highlight {
    color: var(--primary);
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-main);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

/* Navigation */
.app-nav {
    display: flex;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    gap: 4px;
}

.nav-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background-color: rgba(37, 99, 235, 0.05);
}

.nav-icon {
    font-size: 1.25rem;
}

/* Content */
.app-content {
    flex: 1;
    padding: 1.5rem;
}

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

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.view-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Components */

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

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

.btn.primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn.secondary {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn.secondary:hover {
    background-color: var(--border);
    color: var(--text-main);
}

.btn.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
}

input[type="text"],
input[type="email"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Checkbox Custom */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 0.75rem;
}

.checkbox-label.small {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.checkbox-group {
    padding-left: 0.5rem;
    margin-bottom: 0.5rem;
}

.checkbox-label input {
    display: none;
}

.checkbox-custom {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background-color: var(--bg-card);
}

.checkbox-label input:checked+.checkbox-custom {
    background-color: var(--danger);
    border-color: var(--danger);
}

.checkbox-label input:checked+.checkbox-custom::after {
    content: "✓";
    color: white;
    font-weight: bold;
    font-size: 14px;
}

/* Image Upload */
.image-upload-container {
    margin-bottom: 1.5rem;
}

.image-upload-container input[type="file"] {
    display: none;
}

.upload-label {
    display: block;
    width: 100%;
    cursor: pointer;
}

.image-preview {
    width: 100%;
    min-height: 200px;
    max-height: 500px;
    height: auto;
    aspect-ratio: auto;
    background-color: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    padding: 1rem;

    /* Changed from cover to contain for full visibility */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;

    position: relative;
    overflow: hidden;
}

/* When image is loaded, adjust height */
.image-preview.has-image {
    height: 400px;
}

.image-preview.has-image {
    border-style: solid;
}

.image-preview.has-image .placeholder-icon,
.image-preview.has-image p {
    display: none;
}

/* Multi-Page Preview Grid */
.multi-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-body);
    border-radius: var(--radius);
}

.multi-preview.hidden {
    display: none;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 8px;
    border: 2px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.preview-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.preview-page img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 2px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-page span {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.preview-page:hover img {
    transform: scale(1.02);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.preview-page img {
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.preview-item:hover {
    transform: scale(1.05);
    border-color: var(--primary);
}

.preview-item.active {
    border-color: var(--primary);
    border-width: 3px;
    box-shadow: 0 0 0 2px var(--primary);
}

.preview-item .page-number {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.preview-item .remove-page {
    position: absolute;
    top: 4px;
    left: 4px;
    background: var(--danger);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.preview-item:hover .remove-page {
    opacity: 1;
}

.preview-item.pdf-page::after {
    content: 'PDF';
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: var(--primary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}


.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Dashboard Cards */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.note-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
}

.note-card:hover {
    transform: translateY(-4px);
}

.note-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.success {
    background-color: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.badge.danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.note-body {
    padding: 1rem;
    flex: 1;
}

.note-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1rem;
    background-color: var(--bg-body);
}

.note-supplier {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.note-date {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.note-comment {
    background-color: var(--bg-body);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-main);
    border-left: 3px solid var(--danger);
}

.note-actions {
    padding: 1rem;
    background-color: var(--bg-body);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Search Filters */
.search-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.search-filters input[type="text"] {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    min-width: 150px;
    flex: 1;
}

.search-filters .small-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text-main);
    color: var(--bg-body);
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    font-weight: 500;
    box-shadow: var(--shadow);
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s;
}

/* Mini Previews for Reserves */
.mini-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.mini-preview-item {
    width: 150px;
    height: 150px;
    border-radius: 8px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: 2px solid var(--border);
    position: relative;
}

.preview-delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.preview-delete-btn:hover {
    background: rgba(220, 38, 38, 1);
}


.toast.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.close-btn:hover {
    background: var(--border);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body a {
    color: var(--primary);
    text-decoration: none;
}

.modal-body a:hover {
    text-decoration: underline;
}

/* ========================================
   DESKTOP LAYOUT STYLES
   ======================================== */

/* Desktop Layout Container */
.desktop-layout {
    display: none;
    /* Hidden by default, shown via JS on desktop */
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Desktop Top Banner */
.desktop-banner {
    background: #e0f2fe;
    /* Bleu pastel - même couleur que le sidebar */
    border-bottom: 2px solid #bae6fd;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 140px;
    /* Augmenté de 100px à 140px */
    box-shadow: var(--shadow);
    position: relative;
}

.desktop-banner-img {
    height: 110px;
    /* Augmenté de 80px à 110px */
    width: auto;
    object-fit: contain;
}

.desktop-header-actions {
    position: absolute;
    right: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Profile Dropdown */
.profile-dropdown {
    position: relative;
    cursor: pointer;
}

.profile-pic,
.profile-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #0ea5e9;
    transition: transform 0.2s;
}

.profile-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #bae6fd;
    font-size: 1.5rem;
}

.profile-pic:hover,
.profile-placeholder:hover {
    transform: scale(1.1);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 1000;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-user-info {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.dropdown-user-email {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
    word-break: break-all;
}

.dropdown-item {
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
    font-size: 0.95rem;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f0f9ff;
}

.dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

.dropdown-item span {
    font-size: 1.2rem;
}

/* Desktop Main Container (Sidebar + Content) */
.desktop-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar Menu - Bleu Pastel Theme */
.sidebar-menu {
    width: 250px;
    background: #e0f2fe;
    /* Bleu très clair */
    border-right: 2px solid #bae6fd;
    overflow-y: auto;
    padding: 1.5rem 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-section {
    padding: 0 1rem;
}

.sidebar-title {
    font-size: 0.95rem;
    /* Augmenté de 0.75rem à 0.95rem */
    font-weight: 800;
    /* Plus gras : 700 → 800 */
    text-transform: uppercase;
    letter-spacing: 0.08em;
    /* Légèrement plus espacé */
    color: #0c4a6e;
    /* Bleu foncé */
    margin-bottom: 0.75rem;
    padding: 0 0.75rem;
    border-left: 3px solid #0ea5e9;
    /* Barre bleue à gauche */
    padding-left: 0.5rem;
}

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

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    color: #0c4a6e;
    /* Bleu foncé */
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.sidebar-link:hover {
    background: #bae6fd;
    /* Bleu pastel moyen */
    transform: translateX(4px);
}

.sidebar-link.active {
    background: #0ea5e9;
    /* Bleu ciel */
    color: white;
    box-shadow: 0 2px 4px rgba(14, 165, 233, 0.3);
}

.sidebar-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Desktop Content Area */
.desktop-content {
    flex: 1;
    overflow-y: auto;
    /* Permet le scroll quand nécessaire */
    padding: 2rem;
    background: #e0f2fe;
    /* Même couleur que bannière et sidebar */
}

#desktop-view-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Table Styles */
.table-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.table-filter,
.table-search {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid #bae6fd;
    /* Bordure bleu pastel */
    background: #e0f2fe !important;
    /* Fond bleu pastel - force le style */
    color: var(--text-main);
    font-size: 0.9rem;
}

.table-search {
    flex: 1;
    min-width: 250px;
}

.table-container {
    margin-top: 1.5rem;
    background: transparent;
    /* Transparent pour montrer le fond bleu pastel */
    border-radius: var(--radius);
    overflow-y: auto;
    max-height: calc(100vh - 350px);
    /* Hauteur dynamique : viewport - bannière - filtres - padding */
    box-shadow: var(--shadow);
}

/* Custom Scrollbar for table */
.table-container::-webkit-scrollbar {
    width: 10px;
}

.table-container::-webkit-scrollbar-track {
    background: #f0f9ff;
    /* Bleu très clair */
    border-radius: 10px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #0ea5e9;
    /* Bleu ciel - même que sidebar active */
    border-radius: 10px;
    border: 2px solid #f0f9ff;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #0284c7;
    /* Bleu plus foncé au hover */
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table thead {
    background: #e0f2fe;
    /* Bleu pastel */
    color: #0c4a6e;
    /* Bleu foncé */
    position: sticky;
    top: 0;
    z-index: 10;
}

.orders-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.orders-table th:hover {
    background: #bae6fd;
}

.orders-table th[data-sort] {
    position: relative;
}

.sort-icon {
    margin-left: 0.5rem;
    opacity: 0.5;
    font-size: 0.8rem;
}

.orders-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.orders-table tbody tr:hover {
    background: var(--bg-body);
}

.orders-table td {
    padding: 1rem;
}

.action-cell {
    text-align: center;
    width: 80px;
}

.icon-btn-table {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    transition: transform 0.2s, opacity 0.2s;
    opacity: 0.7;
}

.icon-btn-table:hover {
    transform: scale(1.2);
    opacity: 1;
}

/* Send button and dropdown */
.send-cell {
    position: relative;
}

.send-wrapper {
    position: relative;
    display: inline-block;
}

.send-btn {
    font-size: 1.2rem;
}

.send-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 250px;
    z-index: 1000;
    overflow: hidden;
}

.send-dropdown.hidden {
    display: none;
}

.send-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: white;
    text-align: left;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.send-dropdown .dropdown-item:last-child {
    border-bottom: none;
}

.send-dropdown .dropdown-item:hover {
    background: #e0f2fe;
}

.send-dropdown .dropdown-item span {
    font-size: 1.1rem;
}

.table-pagination {
    margin-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.pagination-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.pagination-buttons button {
    min-width: 40px;
}

.pagination-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-buttons span {
    padding: 0 0.5rem;
    color: var(--text-muted);
}

/* Hide mobile layout on desktop */
@media (min-width: 768px) {
    .app-container {
        display: none !important;
    }

    .desktop-layout {
        display: flex !important;
    }
}

/* Hide desktop layout on mobile */
@media (max-width: 767px) {

    /* Blue pastel background for mobile */
    body {
        background-color: #e0f2fe;
    }

    .desktop-layout {
        display: none !important;
    }

    .app-container {
        display: flex !important;
        flex-direction: column;
        height: 100vh;
        padding: 0;
        background: transparent;
    }

    /* Hide old header and nav on mobile */
    .app-header,
    .app-nav {
        display: none !important;
    }


    /* Mobile Banner */
    .mobile-banner {
        background: #e0f2fe;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        padding: 1rem;
        display: flex;
        align-items: center;
        gap: 1rem;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .mobile-banner-logo {
        height: 50px;
        width: auto;
        flex: 1;
        object-fit: contain;
    }

    .mobile-banner-actions {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .mobile-user-profile {
        position: relative;
    }

    .mobile-profile-btn {
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
    }

    .mobile-avatar {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        color: white;
        transition: transform 0.2s;
    }

    .mobile-profile-btn:hover .mobile-avatar {
        transform: scale(1.05);
    }

    .mobile-profile-dropdown {
        position: absolute;
        top: calc(100% + 0.5rem);
        right: 0;
        background: white;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        min-width: 200px;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: all 0.2s ease;
        z-index: 1000;
    }

    .mobile-profile-dropdown.active {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .mobile-profile-info {
        padding: 1rem;
        border-bottom: 1px solid #e2e8f0;
    }

    .mobile-user-email {
        font-size: 0.875rem;
        color: #64748b;
        font-weight: 500;
    }

    .mobile-dropdown-item {
        width: 100%;
        padding: 0.75rem 1rem;
        background: none;
        border: none;
        text-align: left;
        cursor: pointer;
        font-size: 0.875rem;
        color: #0f172a;
        transition: background 0.2s;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .mobile-dropdown-item:hover {
        background: #f1f5f9;
    }

    .mobile-dropdown-item:first-of-type {
        border-radius: 0 0 12px 12px;
    }

    /* Hamburger Menu */
    .hamburger-menu {
        width: 30px;
        height: 24px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        cursor: pointer;
        padding: 0;
        background: none;
        border: none;
    }

    .hamburger-menu span {
        display: block;
        height: 3px;
        background-color: #0f172a;
        border-radius: 2px;
        transition: all 0.3s ease;
    }

    .hamburger-menu.active span:nth-child(1) {
        transform: rotate(45deg) translate(8px, 8px);
    }

    .hamburger-menu.active span:nth-child(2) {
        opacity: 0;
    }

    .hamburger-menu.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }

    /* Mobile Navigation */
    .mobile-nav {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        background: white;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
        transition: left 0.3s ease;
        z-index: 200;
        padding: 1rem;
    }

    .mobile-nav.active {
        left: 0;
    }

    .mobile-nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 150;
    }

    .mobile-nav-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

    .mobile-nav-header {
        padding: 1rem 0;
        border-bottom: 1px solid #e2e8f0;
        margin-bottom: 1rem;
    }

    .mobile-nav-header h2 {
        font-size: 1.25rem;
        color: #0f172a;
        margin: 0;
    }

    .mobile-nav-items {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .mobile-nav-item {
        padding: 0.75rem 1rem;
        margin-bottom: 0.5rem;
        border-radius: 8px;
        cursor: pointer;
        transition: background 0.2s;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        color: #0f172a;
        font-weight: 500;
    }

    .mobile-nav-item:hover {
        background: #f1f5f9;
    }

    .mobile-nav-item.active {
        background: #e0f2fe;
        color: #2563eb;
    }

    /* Mobile Content */
    .mobile-content {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
    }

    /* Mobile Orders List */
    .mobile-search-input {
        width: 100%;
        padding: 0.75rem 1rem;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        font-size: 0.875rem;
        margin-bottom: 1rem;
    }

    .mobile-orders-list {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .mobile-order-card {
        background: white;
        border-radius: 12px;
        padding: 1rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .mobile-order-header {
        display: flex;
        justify-content: space-between;
        align-items: start;
        margin-bottom: 0.75rem;
        padding-bottom: 0.75rem;
        border-bottom: 1px solid #e2e8f0;
    }

    .mobile-order-supplier {
        font-weight: 600;
        color: #0f172a;
        font-size: 1rem;
    }

    .mobile-order-number {
        font-size: 0.875rem;
        color: #64748b;
        margin-top: 0.25rem;
    }

    .mobile-order-status {
        padding: 0.25rem 0.75rem;
        border-radius: 12px;
        font-size: 0.75rem;
        font-weight: 600;
    }

    .mobile-order-status.non {
        background: #dcfce7;
        color: #16a34a;
    }

    .mobile-order-status.oui {
        background: #fee2e2;
        color: #dc2626;
    }

    .mobile-order-details {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .mobile-order-detail {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.875rem;
        color: #64748b;
    }

    .mobile-order-actions {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.75rem;
    }

    .mobile-order-btn {
        flex: 1;
        padding: 0.5rem;
        border: none;
        border-radius: 8px;
        font-size: 0.875rem;
        cursor: pointer;
        transition: background 0.2s;
    }

    .mobile-order-btn.view {
        background: #e0f2fe;
        color: #0369a1;
    }

    .mobile-order-btn.send {
        background: #2563eb;
        color: white;
    }
}

/* Responsive */
@media (max-width: 640px) {

    /* Header */
    .app-header {
        padding: 0.75rem 1rem;
    }

    .logo {
        font-size: 1rem;
    }

    .logo h1 {
        font-size: 1rem;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
        font-size: 1.25rem;
    }

    /* Navigation */
    .nav-btn {
        padding: 0.6rem 0.5rem;
        font-size: 0.8rem;
    }

    .nav-icon {
        font-size: 1.1rem;
    }

    /* Content */
    .app-content {
        padding: 1rem;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 1rem;
    }

    .view-header h2 {
        font-size: 1.25rem;
    }

    /* Search */
    .search-bar input {
        width: 100%;
        min-width: unset;
    }

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

    input[type="text"],
    input[type="email"],
    input[type="date"],
    textarea {
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .form-actions {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .form-actions .btn {
        width: 100%;
    }

    /* Image Upload */
    .image-preview {
        min-height: 180px;
        padding: 1.5rem;
    }

    .placeholder-icon {
        font-size: 2.5rem;
    }

    /* Dashboard Cards */
    .notes-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .note-card {
        margin-bottom: 0;
    }

    .note-actions {
        flex-wrap: wrap;
        justify-content: stretch;
    }

    .note-actions .btn {
        flex: 1;
        min-width: 120px;
    }

    /* Modal */
    .modal-content {
        width: 95%;
        max-height: 85vh;
    }

    .modal-header,
    .modal-body {
        padding: 1rem;
    }

    .modal-header h2 {
        font-size: 1.1rem;
    }

    /* Toast */
    .toast {
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        transform: none;
        max-width: calc(100% - 2rem);
    }

    /* Input with status */
    .input-with-status {
        position: relative;
    }

    .status-text {
        font-size: 0.7rem;
        right: 8px;
    }
}

/* Extra small devices */
@media (max-width: 375px) {
    .app-header {
        padding: 0.5rem 0.75rem;
    }

    .logo {
        font-size: 0.9rem;
        gap: 0.25rem;
    }

    .icon-btn {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }

    .nav-btn {
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
    }

    .app-content {
        padding: 0.75rem;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

/* Landscape mobile */
@media (max-width: 900px) and (orientation: landscape) {
    .app-header {
        position: relative;
    }

    .image-preview {
        min-height: 150px;
    }

    .modal-content {
        max-height: 80vh;
    }
}

/* Tablet */
@media (min-width: 641px) and (max-width: 1024px) {
    .notes-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .app-content {
        padding: 1.25rem;
    }
}

/* ===========================
   LOGIN PAGE & AUTHENTICATION
   =========================== */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
    padding: 1rem;
}

.login-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.login-banner {
    max-width: 200px;
    height: auto;
    margin-bottom: 1.5rem;
}

.login-container h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

#google-signin-button {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
}

.login-error {
    display: none;
    background: #fee2e2;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* User Info in Header */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Logout Button */
#logout-btn {
    transition: transform 0.2s;
}

#logout-btn:hover {
    transform: scale(1.1);
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .login-container {
        padding: 2rem 1.5rem;
    }

    .login-container h1 {
        font-size: 1.5rem;
    }

    .user-name {
        display: none;
    }

    .user-info {
        padding: 0.25rem;
    }
}

/* OCR Loading Overlay */
.ocr-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.ocr-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-content {
    background: var(--bg-card);
    padding: 2.5rem 3rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 90%;
}

/* Truck Loader Animation */
.truck-loader {
    position: relative;
    width: 220px;
    height: 140px;
    margin: 0 auto 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.truck {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    animation: truck-bounce 0.6s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.truck-cabin {
    width: 45px;
    height: 40px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    border-radius: 6px 6px 0 0;
    position: relative;
    left: 0;
    box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.1);
}

.truck-cabin::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 18px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.2) 100%);
    top: 6px;
    left: 6px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.truck-cargo {
    width: 75px;
    height: 50px;
    background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
    position: absolute;
    left: 45px;
    top: -10px;
    border-radius: 0 6px 0 0;
    box-shadow: inset -3px -3px 6px rgba(0, 0, 0, 0.15);
}

.truck-wheel {
    width: 18px;
    height: 18px;
    background: radial-gradient(circle, #1f2937 40%, #0f172a 100%);
    border-radius: 50%;
    position: absolute;
    bottom: -9px;
    animation: wheel-spin 0.4s linear infinite;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 0 0 3px #374151;
}

.truck-wheel::before {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: #6b7280;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.truck-wheel-front {
    left: 10px;
}

.truck-wheel-back {
    left: 90px;
}

.packages {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(calc(20% + 20px));
    display: flex;
    gap: 0;
    z-index: 1;
}

.package {
    font-size: 32px;
    opacity: 0;
    transform: translateY(-20px);
    animation: package-drop 2.8s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    position: absolute;
    left: 0;
}

.package-1 {
    animation-delay: 0s;
}

.package-2 {
    animation-delay: 1.4s;
}



.road {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    height: 3px;
    background: repeating-linear-gradient(90deg,
            var(--border) 0px,
            var(--border) 10px,
            transparent 10px,
            transparent 20px);
    animation: road-move 0.5s linear infinite;
}

@keyframes truck-bounce {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-5px);
    }
}

@keyframes wheel-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes package-drop {
    0% {
        opacity: 0;
        transform: translateY(-70px) scale(0.6);
    }

    15% {
        opacity: 0.7;
        transform: translateY(-40px) scale(0.75);
    }

    35% {
        opacity: 0.7;
        transform: translateY(5px) scale(0.8);
    }

    45% {
        opacity: 0.7;
        transform: translateY(10px) scale(0.85);
    }

    50% {
        opacity: 0.7;
        transform: translateY(8px) scale(0.83);
    }

    55% {
        opacity: 0.7;
        transform: translateY(10px) scale(0.85);
    }

    /* Slower synchronized bounce with truck - starts at 55% */
    62% {
        opacity: 0.7;
        transform: translateY(7px) scale(0.85);
    }

    69% {
        opacity: 0.7;
        transform: translateY(10px) scale(0.85);
    }

    76% {
        opacity: 0.7;
        transform: translateY(7px) scale(0.85);
    }

    83% {
        opacity: 0.7;
        transform: translateY(10px) scale(0.85);
    }

    90% {
        opacity: 0.7;
        transform: translateY(7px) scale(0.85);
    }

    95% {
        opacity: 0.4;
        transform: translateY(10px) scale(0.75);
    }

    100% {
        opacity: 0;
        transform: translateY(10px) scale(0.6);
    }
}

@keyframes road-move {
    to {
        background-position: 20px 0;
    }
}

.loader-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.loader-subtext {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ========================================
   EMAIL LOADER STYLES
   ======================================== */

.email-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.email-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Email Animation Container */
.email-animation {
    position: relative;
    width: 280px;
    height: 220px;
    margin: 0 auto 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Envelope */
.envelope {
    position: relative;
    width: 120px;
    height: 80px;
    margin-top: 40px;
}

.envelope-body {
    width: 120px;
    height: 80px;
    background: linear-gradient(135deg, #ffffff 0%, #e0f2fe 100%);
    border: 3px solid #2563eb;
    border-radius: 6px;
    position: relative;
    z-index: 1;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Decorative lines on envelope */
.envelope-body::before {
    content: '';
    position: absolute;
    width: 70%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #93c5fd, transparent);
    top: 30%;
    left: 15%;
}

.envelope-body::after {
    content: '';
    position: absolute;
    width: 50%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #93c5fd, transparent);
    top: 50%;
    left: 25%;
}

.envelope-flap {
    width: 0;
    height: 0;
    border-left: 60px solid transparent;
    border-right: 60px solid transparent;
    border-bottom: 50px solid #2563eb;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    transform-origin: top center;
    animation: flap-open 3s ease-in-out infinite;
    filter: drop-shadow(0 2px 8px rgba(37, 99, 235, 0.4));
}

/* Inner flap detail */
.envelope-flap::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-bottom: 40px solid #60a5fa;
    top: 10px;
    left: -50px;
}

.letter {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translate(-50%, 0);
    font-size: 40px;
    z-index: 2;
    animation: letter-fly-out 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

/* Sparkles around letter */
.letter::before {
    content: '✨';
    position: absolute;
    top: -10px;
    left: -30px;
    font-size: 20px;
    animation: sparkle-1 3s ease-in-out infinite;
}

.letter::after {
    content: '✨';
    position: absolute;
    top: -10px;
    right: -30px;
    font-size: 20px;
    animation: sparkle-2 3s ease-in-out infinite;
}

/* Clouds - now with more movement */
.clouds {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.cloud {
    position: absolute;
    font-size: 32px;
    opacity: 0.5;
    animation: cloud-drift 6s ease-in-out infinite;
}

.cloud-1 {
    top: 10%;
    left: 5%;
    animation-delay: 0s;
}

.cloud-2 {
    top: 70%;
    right: 10%;
    animation-delay: 2s;
    font-size: 26px;
}

.cloud-3 {
    top: 35%;
    right: 5%;
    animation-delay: 4s;
    font-size: 28px;
}

/* Animations */
@keyframes flap-open {

    0%,
    20% {
        transform: rotateX(0deg);
    }

    30%,
    70% {
        transform: rotateX(-180deg);
    }

    80%,
    100% {
        transform: rotateX(0deg);
    }
}

@keyframes letter-fly-out {

    0%,
    20% {
        transform: translate(-50%, 0) scale(0.5);
        opacity: 0;
    }

    30% {
        transform: translate(-50%, 0) scale(0.8);
        opacity: 1;
    }

    40%,
    60% {
        transform: translate(-50%, -80px) scale(1) rotate(5deg);
        opacity: 1;
    }

    70% {
        transform: translate(-50%, -100px) scale(0.9) rotate(10deg);
        opacity: 0.7;
    }

    80%,
    100% {
        transform: translate(-50%, -120px) scale(0.6) rotate(15deg);
        opacity: 0;
    }
}

@keyframes sparkle-1 {

    0%,
    30% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }

    40% {
        opacity: 1;
        transform: scale(1) rotate(180deg);
    }

    60% {
        opacity: 1;
        transform: scale(1.2) rotate(360deg);
    }

    70%,
    100% {
        opacity: 0;
        transform: scale(0) rotate(540deg);
    }
}

@keyframes sparkle-2 {

    0%,
    30% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }

    45% {
        opacity: 1;
        transform: scale(1) rotate(-180deg);
    }

    65% {
        opacity: 1;
        transform: scale(1.2) rotate(-360deg);
    }

    75%,
    100% {
        opacity: 0;
        transform: scale(0) rotate(-540deg);
    }
}

@keyframes cloud-drift {

    0%,
    100% {
        transform: translateX(0) translateY(0);
        opacity: 0.3;
    }

    50% {
        transform: translateX(20px) translateY(-10px);
        opacity: 0.6;
    }
}