/* Weight and Quantity inline on mobile */
@media (max-width: 600px) {
    .weight-quantity-row {
        flex-direction: row !important;
        gap: 10px !important;
    }
    .weight-quantity-row .form-group {
        margin-bottom: 0 !important;
    }
}
/* Shipment Modal: Date/Time row mobile fix */
@media (max-width: 600px) {
    .shipment-datetime-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }
    .shipment-datetime-row .form-group {
        width: 100% !important;
        margin-bottom: 0 !important;
    }
    .shipment-datetime-row input[type="datetime-local"] {
        font-size: 16px !important; /* iOS fix for input zoom/overflow */
        width: 100% !important;
        box-sizing: border-box;
        min-height: 48px; /* Match height with other inputs */
        background-color: #ffffff; /* Override iOS gray background */
        appearance: none; /* Remove native iOS styling */
        -webkit-appearance: none;
    }
}
/* Admin CSS */
:root {
    --admin-bg: #f8fafc;
    --admin-sidebar: #0f172a;
    --admin-accent: #3b82f6;
    --admin-card-bg: #ffffff;
    --admin-text-main: #1e293b;
    --admin-text-muted: #64748b;
    --admin-border: #e2e8f0;
     /* Force browsers to use light mode */
     color-scheme: light;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.desktop-only {
    display: table-cell;
}

.mobile-only {
    display: none;
}

/* Login Page Styles */
.login-body {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Roboto', sans-serif;
}

.login-card {
        background: rgba(255, 255, 255, 0.05);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 16px;
        padding: 24px 40px 40px 40px;
        width: 100%;
        max-width: 400px;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
        text-align: center;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        height: auto;
}

@media (max-width: 600px) {
        #shipment-modal .modal-body > form > div[style*='grid-template-columns: repeat(3, 1fr)'] {
            display: flex !important;
            flex-direction: column !important;
            gap: 16px !important;
        }
        #shipment-modal .modal-body > form > div[style*='grid-template-columns: repeat(3, 1fr)'] .form-group,
        #shipment-modal .modal-body > form > div[style*='grid-template-columns: repeat(3, 1fr)'] input {
            width: 100% !important;
            max-width: none !important;
            margin-left: 0 !important;
            margin-right: 0 !important;
            box-sizing: border-box;
        }
    .login-card {
        height: 100dvh;
        min-height: 100dvh;
        box-sizing: border-box;
        border-radius: 0;
        max-width: 100vw;
        padding-left: 16px;
        padding-right: 16px;
        justify-content: space-between;
    }
    .login-form {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    .login-btn {
        margin-top: auto;
        margin-bottom: 0;
        width: 100%;
        align-self: flex-end;
    }
}

@media (max-width: 600px) {
    .login-card {
        height: 100dvh;
        min-height: 100dvh;
        box-sizing: border-box;
        border-radius: 0;
        max-width: 100vw;
        padding-left: 16px;
        padding-right: 16px;
    }
}

.login-logo {
    font-family: 'Roboto Condensed', sans-serif;
    font-size: 28px;
    color: white;
    margin-bottom: 30px;
    display: block;
    text-decoration: none;
    font-weight: 700;
}

.login-logo span {
    color: var(--sn-blue, #2daae1);
}

.login-title {
    color: white;
    font-size: 24px;
    margin-bottom: 10px;
}

.login-card p {
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 30px;
}

.login-form .form-group {
    margin-bottom: 20px;
    text-align: left;
    position: relative;
}

.login-form label {
    display: block;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
    font-size: 14px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 16px;
    transition: all 0.3s ease;
}

.password-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: color 0.3s;
    z-index: 10;
}

.password-toggle:hover {
    color: white;
}

.login-form input:focus {
    outline: none;
    border-color: var(--sn-blue, #2daae1);
    background: rgba(255, 255, 255, 0.15);
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--sn-blue, #2daae1);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    margin-top: 10px;
}

.login-btn:hover {
    background: #2595c7;
    transform: translateY(-2px);
}

/* Action Buttons */
.action-btns {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-view {
    background: #f1f5f9;
    color: #64748b;
}

.btn-view:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.btn-edit {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.btn-edit:hover {
    background: #3b82f6;
    color: white;
}

.btn-delete {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.btn-delete:hover {
    background: #ef4444;
    color: white;
}

/* Click to Copy Tracking ID */
.copy-id {
    cursor: pointer;
    position: relative;
    padding-right: 22px;
    transition: all 0.2s;
    user-select: none;
}

.copy-id:hover {
    color: var(--admin-accent);
}

.copy-id::after {
    content: '\f0c5';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    opacity: 0.4;
    transition: all 0.2s;
}

.copy-id:hover::after {
    opacity: 1;
}

.copy-id.copied {
    color: #22c55e !important;
}

.copy-id.copied::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: #22c55e;
    opacity: 1;
}

/* Dashboard Styles */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    background: var(--admin-bg);
}

.sidebar {
    width: 260px;
    background: var(--admin-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.sidebar-header {
    padding: 12px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    align-items: center;
}

.sidebar-logo {
    display: block;
    text-decoration: none;
    font-family: 'Roboto Condensed', sans-serif;
    font-weight: 700;
    color: white;
    font-size: 18px;
}

.sidebar-logo i {
    color: var(--sn-blue, #2daae1);
    font-size: 24px;
}

.sidebar-logo span {
    color: var(--sn-blue, #2daae1);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.3s;
    gap: 12px;
}

.nav-link:hover,
.nav-link.active {
    color: white;
    background: rgba(255, 255, 255, 0.05);
    border-left: 4px solid var(--admin-accent);
}

#logout-btn:hover {
    border-left: none;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 40px;
}

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--admin-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-info h3 {
    font-size: 24px;
    margin-bottom: 4px;
    color: var(--admin-text-main);
}

.stat-info p {
    color: var(--admin-text-muted);
    font-size: 14px;
}

.data-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.card-title {
    padding: 20px 24px;
    border-bottom: 1px solid var(--admin-border);
    font-weight: 600;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    background: #f8fafc;
    padding: 12px 24px;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--admin-text-muted);
    font-weight: 600;
}

td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--admin-border);
    font-size: 14px;
    color: var(--admin-text-main);
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-blue {
    background: #dbeafe;
    color: #1e40af;
}

.badge-green {
    background: #dcfce7;
    color: #166534;
}

.badge-yellow {
    background: #fef9c3;
    color: #854d0e;
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 992px) {
    .main-content {
        padding: 24px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 2000;
        transition: transform 0.3s ease;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        z-index: 1999;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
        padding-top: 80px;
    }

    .header-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }

    /* Mobile Dropdown Actions */
    .mobile-actions-wrapper {
        position: relative;
        display: inline-block;
    }

    .mobile-actions-toggle {
        background: #f1f5f9;
        border: none;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        color: #64748b;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s;
    }

    .mobile-actions-toggle:active {
        background: #e2e8f0;
        transform: scale(0.9);
    }

    .mobile-actions-dropdown {
        display: none;
        position: absolute;
        right: 0;
        top: 40px;
        background: white;
        border-radius: 8px;
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
        border: 1px solid var(--admin-border);
        z-index: 100;
        min-width: 160px;
        overflow: hidden;
        flex-direction: column;
        /* Vertical list */
    }

    .mobile-actions-dropdown.show {
        display: flex;
        animation: slideIn 0.2s ease-out;
    }

    .dropdown-item {
        width: 100%;
        padding: 12px 16px;
        border: none;
        background: none;
        display: flex;
        align-items: center;
        gap: 12px;
        font-size: 14px;
        color: var(--admin-text-main);
        cursor: pointer;
        transition: all 0.2s;
        text-align: left;
    }

    .dropdown-item:hover {
        background: #f8fafc;
        transform: none;
        /* Remove previous scale effect */
    }

    .dropdown-item i {
        width: 16px;
        text-align: center;
        font-size: 14px;
    }

    @keyframes slideIn {
        from {
            opacity: 0;
            transform: translateY(-5px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .data-card {
        border-radius: 8px;
    }

    .login-card {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        border-radius: 0;
        border: none;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        padding: 40px 24px;
    }

    .login-body {
        height: 100dvh;
        overflow: hidden;
    }

    .login-form {
        display: flex;
        flex-direction: column;
        flex: 1;
    }

    .login-btn {
        margin-top: auto;
    }

    /* Mobile Table adjustments */
    table thead {
        display: none;
        /* Keep headers hidden to save space */
    }

    table {
        display: table;
        width: 100%;
        border-collapse: collapse;
    }

    table tbody {
        display: table-row-group;
    }

    table tr {
        display: table-row;
        border-bottom: 1px solid var(--admin-border);
    }

    table td {
        display: table-cell;
        text-align: left;
        vertical-align: middle;
        padding: 12px 8px;
        font-size: 13px;
        border-bottom: 1px solid var(--admin-border);
    }

    table td:first-child {
        padding-left: 16px;
    }

    table td:last-child {
        padding-right: 16px;
        text-align: right;
    }

    /* Remove the stacked labels */
    table td::before {
        display: none !important;
    }

    /* Remove icons from tracking ID copy action on mobile */
    .copy-id::after {
        display: none !important;
    }

    .copy-id {
        padding-right: 0;
    }

    /* Recent Shipments: Show only 2 on mobile */
    #section-overview .shipments-list tr:nth-child(n+3) {
        display: none;
    }
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    z-index: 999;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.mobile-toggle {
    background: none;
    color: var(--admin-text-main);
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--admin-text-main);
    text-transform: capitalize;
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .mobile-toggle {
        display: flex;
        /* Ensure it's visible inside header */
        position: static;
        /* Reset fixed positioning */
        width: auto;
        height: auto;
        background: transparent;
        border-radius: 0;
    }

    /* Hide redundant page titles on mobile */
    .header-actions h1 {
        display: none;
    }
}

/* Modal Styles */
@media (max-width: 600px) {
    #shipment-modal .modal-body > form > div[style*='grid-template-columns: repeat(2, 1fr)'] .form-group,
    #shipment-modal .modal-body > form > div[style*='grid-template-columns: repeat(2, 1fr)'] input {
        width: 100% !important;
        max-width: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box;
    }
    #change-password-modal .modal-content {
        max-width: 100vw !important;
        width: 100vw !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
        border-radius: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
    }
    #change-password-modal .modal-body {
        padding: 16px !important;
    }
    #change-password-modal .modal-header {
        padding: 16px !important;
    }
}
@media (max-width: 600px) {
    #shipment-modal .modal-body > form > div[style*='grid-template-columns: repeat(2, 1fr)'] {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }
    #shipment-modal .modal-body > form > div[style*='grid-template-columns: repeat(2, 1fr)'] .form-group,
    #shipment-modal .modal-body > form > div[style*='grid-template-columns: repeat(2, 1fr)'] input {
        width: 100% !important;
        box-sizing: border-box;
    }
}
@media (max-width: 600px) {
    #shipment-modal .modal-content {
        max-width: 100vw !important;
        width: 100vw !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
        border-radius: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
    }
    #shipment-modal .modal-body {
        padding: 16px !important;
    }
    #shipment-modal .modal-header {
        padding: 16px !important;
    }
    #shipment-modal .modal-body > form > div[style*='grid-template-columns: 1fr 1fr'] {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }
    #shipment-modal .form-group,
    #shipment-modal input,
    #shipment-modal select {
        width: 100% !important;
        box-sizing: border-box;
    }
    #shipment-modal h4 {
        margin-top: 16px;
    }

    /* Make close-modal button bigger on mobile */
    .close-modal {
        font-size: 32px !important;
        width: 48px !important;
        height: 48px !important;
        line-height: 48px !important;
        display: flex;
        align-items: center;
        justify-content: center;
        top: 8px;
        right: 8px;
    }

    /* Edit Modal: Match new shipment modal on mobile */
    #edit-shipment-modal .modal-content {
        max-width: 100vw !important;
        width: 100vw !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
        border-radius: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
    }
    #edit-shipment-modal .modal-body {
        padding: 16px !important;
    }
    #edit-shipment-modal .modal-header {
        padding: 16px !important;
    }
    #edit-shipment-modal .modal-body > form > div[style*='grid-template-columns: 1fr 1fr'] {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }
    #edit-shipment-modal .form-group,
    #edit-shipment-modal input,
    #edit-shipment-modal select {
        width: 100% !important;
        box-sizing: border-box;
    }
    #edit-shipment-modal h4 {
        margin-top: 16px;
    }
}
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #1e293b;
    padding: 0;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: all 0.3s ease;
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.modal-content::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari and Opera */
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    position: sticky;
    top: 0;
    background: #1e293b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.modal-header h3 {
    color: white;
    margin: 0;
}

.close-modal {
    color: rgba(255, 255, 255, 0.5);
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    transition: color 0.3s;
}

.close-modal:hover {
    color: white;
}

.modal-body {
    padding: 30px;
}

.modal-body p {
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 20px;
    font-size: 14px;
}

/* Shipment Modal Light Theme & Field Consistency */
#shipment-modal .modal-content {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-width: 800px; /* Increased width for shipment form */
}

#shipment-modal .modal-header {
    background: #1e293b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#shipment-modal .modal-header h3 {
    color: #fff !important;
    font-weight: 700 !important;
    font-size: 1.25rem !important;
    margin: 0;
}

#shipment-modal .close-modal {
    color: var(--admin-text-muted);
}
#shipment-modal .close-modal:hover {
    color: var(--admin-text-main);
}
#shipment-modal .modal-body p {
    color: var(--admin-text-muted);
}

/* Responsive Grid Form */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Notification Modal Loading State */
.notif-btn {
    position: relative;
    transition: all 0.3s;
}

.notif-btn.loading {
    color: transparent !important;
    pointer-events: none;
}

.notif-btn.loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    margin-left: -9px;
    margin-top: -9px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: notif-spin 0.8s linear infinite;
}

@keyframes notif-spin {
    to { transform: rotate(360deg); }
}

/* Pagination Styles */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 20px 0;
}
.pagination-controls button {
    background: white;
    border: 1px solid var(--admin-border);
    color: var(--admin-text-muted);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 40px;
}
.pagination-controls button:hover:not(:disabled) {
    background: var(--admin-accent);
    color: white;
    border-color: var(--admin-accent);
}
.pagination-controls button.active {
    background: var(--admin-accent);
    color: white;
    border-color: var(--admin-accent);
    font-weight: bold;
}
.pagination-controls button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.pagination-controls span {
    color: var(--admin-text-muted);
    padding: 0 5px;
    align-self: center;
}