/* Custom Styles for Shamirik Shipper */

:root {
    --primary-color: #DA041B;
    --primary-dark: #b00315;
    --primary-light: #ff1a35;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --dark-color: #343a40;
    --light-color: #f8f9fa;
    --sidebar-width: 260px;
    --sidebar-bg: #1a1d29;
    --sidebar-text: #a0a6b8;
    --sidebar-hover: #252836;
}

/* Google Font - Quicksand */
* {
    box-sizing: border-box;
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f7fa;
    margin: 0;
    padding: 0;
    color: #333;
}

body.has-sidebar {
    padding-left: var(--sidebar-width);
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    transition: all 0.3s;
}

.sidebar-brand i {
    font-size: 1.5rem;
    margin-right: 0.75rem;
    color: var(--primary-color);
}

.sidebar-brand:hover {
    color: #fff;
    transform: translateX(2px);
}

.brand-text {
    font-weight: 600;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}

.sidebar-user {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Exchange Rates in Sidebar */
.sidebar-exchange-rates {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
}

.exchange-rate-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.exchange-rate-item:last-child {
    margin-bottom: 0;
}

.exchange-label {
    color: var(--sidebar-text);
    font-weight: 500;
    flex: 1;
}

.exchange-value {
    color: #fff;
    font-weight: 600;
    margin: 0 0.5rem;
    flex: 1;
    text-align: right;
}

.exchange-edit-btn {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.exchange-edit-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--primary-color);
}

.exchange-edit-btn i {
    margin: 0;
    font-size: 0.9rem;
}

/* Cost Input Groups */
.input-group-text.cost-tzs {
    min-width: 120px;
    font-weight: 600;
    color: var(--primary-color);
    background-color: #f8f9fa;
    border-left: none;
}

.input-group .form-control {
    border-right: none;
}

.input-group .form-control:focus {
    border-right: 1px solid var(--primary-color);
    z-index: 3;
}

.input-group .form-control:focus + .input-group-text {
    border-color: var(--primary-color);
}

/* Currency Badge Add-on */
.currency-badge {
    background-color: #e9ecef;
    color: #495057;
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 55px;
    text-align: center;
    border-right: none;
    transition: all 0.3s;
}

.input-group .currency-badge + .form-control {
    border-left: none;
}

.input-group .form-control:focus {
    border-left: 1px solid var(--primary-color);
    z-index: 3;
}

.input-group .form-control:focus ~ .input-group-text {
    border-color: var(--primary-color);
}

/* Cost TZS Display */
.cost-tzs {
    background-color: #e9ecef;
    color: #495057;
    font-weight: 600;
    min-width: 100px;
    text-align: center;
}

/* Currency Switch Toggle */
.currency-switch {
    display: inline-flex;
    align-items: center;
}

.currency-toggle {
    display: none;
}

.currency-switch-label {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 28px;
    background-color: #28a745;
    border-radius: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin: 0;
}

.currency-toggle:checked + .currency-switch-label {
    background-color: var(--primary-color);
}

.currency-toggle:not(:checked) + .currency-switch-label {
    background-color: #28a745;
}

.currency-switch-label::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #fff;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.currency-toggle:checked + .currency-switch-label::before {
    transform: translateX(32px);
}

.currency-label-usd,
.currency-label-aed {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    font-weight: 600;
    transition: color 0.3s;
    z-index: 1;
}

.currency-label-usd {
    left: 8px;
    color: #fff;
}

.currency-label-aed {
    right: 8px;
    color: rgba(255,255,255,0.7);
}

.currency-toggle:checked + .currency-switch-label .currency-label-usd {
    color: rgba(255,255,255,0.7);
}

.currency-toggle:checked + .currency-switch-label .currency-label-aed {
    color: #fff;
}

.currency-toggle:not(:checked) + .currency-switch-label .currency-label-usd {
    color: #fff;
}

.currency-toggle:not(:checked) + .currency-switch-label .currency-label-aed {
    color: rgba(255,255,255,0.7);
}

.form-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.form-label .currency-switch {
    margin-left: auto;
}

.form-label.small {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

/* Compact filter form */
.card-body.py-2 {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
}

.form-select-sm,
.form-control-sm {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    color: #fff;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--sidebar-text);
    text-transform: capitalize;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin: 0.25rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.3s;
    font-weight: 500;
    font-size: 0.95rem;
    border-left: 3px solid transparent;
}

.nav-link i {
    font-size: 1.1rem;
    width: 24px;
    margin-right: 0.75rem;
    text-align: center;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: var(--primary-color);
}

/* Submenu Styles */
.nav-item.has-submenu .nav-link {
    position: relative;
}

.nav-item.has-submenu .nav-link .submenu-icon {
    margin-left: auto;
    transition: transform 0.3s ease;
    font-size: 0.85rem;
}

.nav-item.has-submenu .nav-link[aria-expanded="true"] .submenu-icon,
.nav-item.has-submenu .nav-link.collapsed .submenu-icon {
    transform: rotate(0deg);
}

.nav-item.has-submenu .nav-link:not(.collapsed) .submenu-icon {
    transform: rotate(180deg);
}

.nav-submenu {
    background: rgba(0, 0, 0, 0.2);
    padding-left: 0;
    margin: 0;
    list-style: none;
}

.nav-submenu .nav-item {
    margin: 0;
}

.nav-submenu .nav-link {
    padding-left: 3rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    font-size: 0.9rem;
    position: relative;
}

.nav-submenu .nav-link::before {
    content: '';
    position: absolute;
    left: 2.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    background: var(--sidebar-text);
    border-radius: 50%;
    opacity: 0.5;
}

.nav-submenu .nav-link:hover::before,
.nav-submenu .nav-link.active::before {
    background: var(--primary-color);
    opacity: 1;
}

.nav-submenu .nav-link.active {
    background: rgba(218, 4, 27, 0.1);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.nav-link.active {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.nav-link .badge {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 0.25em 0.5em;
}

/* Top Bar */
.top-bar {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 0.75rem 2rem;
    margin: -2rem -2rem 2rem -2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-content {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.top-bar-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: #495057;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: 6px;
    transition: all 0.3s;
}

.top-bar-link:hover {
    background-color: #f8f9fa;
    color: var(--primary-color);
}

.top-bar-link.text-danger:hover {
    background-color: #fff5f5;
    color: #dc3545;
}

.top-bar-link i {
    font-size: 1.1rem;
    margin: 0;
}

@media (max-width: 767.98px) {
    .top-bar {
        padding: 0.75rem 1rem;
        margin: -1rem -1rem 1rem -1rem;
    }
    
    .top-bar-link {
        padding: 0.5rem 0.75rem;
    }
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--primary-color);
    color: #fff;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Main Content */
.main-content {
    min-height: 100vh;
    padding: 2rem;
    transition: margin-left 0.3s;
}

@media (max-width: 767.98px) {
    body.has-sidebar {
        padding-left: 0;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        padding: 1rem;
        padding-top: 4rem;
    }
}

/* Primary color utilities */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 600;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.text-primary {
    color: var(--primary-color) !important;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.border-primary {
    border-color: var(--primary-color) !important;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
    border-radius: 12px;
    background: #fff;
}

.card-header {
    background-color: #fff;
    border-bottom: 2px solid var(--primary-color);
    font-weight: 600;
    padding: 1.25rem 1.5rem;
    border-radius: 12px 12px 0 0;
    font-size: 1.1rem;
}

.card-body {
    padding: 1.5rem;
}

/* Forms */
.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #495057;
    font-size: 0.9rem;
}

.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    padding: 0.75rem 1rem;
    font-weight: 500;
    transition: all 0.3s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(218, 4, 27, 0.15);
    outline: none;
}

/* Tables */
.table {
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.table thead th {
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    font-weight: 600;
    padding: 1rem;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.table-sm thead th {
    padding: 0.75rem 0.5rem;
    font-size: 0.75rem;
}

.table tbody tr {
    transition: all 0.2s;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

.table-sm tbody tr:hover {
    transform: none;
}

.table td {
    padding: 1rem;
    vertical-align: middle;
}

.table-sm td {
    padding: 0.5rem;
    font-size: 0.875rem;
}

/* Shipment Type Icons */
.shipment-type-icon {
    cursor: help;
    transition: transform 0.2s ease, opacity 0.2s ease;
    display: inline-block;
}

.shipment-type-icon:hover {
    transform: scale(1.2);
    opacity: 0.8;
}

.table td:has(.shipment-type-icon) {
    text-align: center;
    vertical-align: middle;
}

/* Smooth transitions for AJAX updates */
#shipments-table-container {
    transition: opacity 0.3s ease;
}

#shipments-table-container.fade-out {
    opacity: 0.5;
}

#shipments-loading {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.table tfoot th {
    background-color: #343a40;
    color: #fff;
    border: none;
    font-weight: 600;
    padding: 1rem;
    text-transform: uppercase;
    font-size: 0.85rem;
}

/* DataTables Integration */
.data-table thead th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table thead th.sortable:hover {
    background-color: var(--primary-dark);
}

/* Badges */
.badge {
    padding: 0.4em 0.7em;
    font-weight: 600;
    border-radius: 6px;
    font-size: 0.8rem;
}

/* Alerts */
.alert {
    border-radius: 10px;
    border: none;
    padding: 1rem 1.25rem;
    font-weight: 500;
}

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 600;
    padding: 0.625rem 1.25rem;
    transition: all 0.3s;
    border: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1.05rem;
}

/* Icons */
i {
    margin-right: 0.25rem;
}

/* Dashboard stats */
.stat-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #fff;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(218, 4, 27, 0.3);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    line-height: 1;
}

.stat-card p {
    margin: 0.75rem 0 0 0;
    opacity: 0.95;
    font-weight: 500;
    font-size: 0.95rem;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: #1a1d29;
}

h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

/* Loading spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Responsive utilities */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table thead th,
    .table td {
        padding: 0.75rem 0.5rem;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-group {
        width: 100%;
    }
    
    .btn-group .btn {
        flex: 1;
    }
    
    h2 {
        font-size: 1.5rem;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .btn,
    .no-print {
        display: none !important;
    }
    
    body.has-sidebar {
        padding-left: 0;
    }
    
    .main-content {
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Utilities */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075) !important;
}

/* Scrollbar styling for sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

/* Login Page Styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: block;
}

.login-header h2 {
    font-weight: 700;
    color: #1a1d29;
    margin: 0;
    font-size: 1.75rem;
}

.login-form {
    margin-top: 1.5rem;
}

/* Password Toggle Styles */
.password-input-wrapper {
    position: relative;
}

.password-toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.password-toggle-btn:hover {
    color: var(--primary-color);
}

.password-toggle-btn:focus {
    outline: none;
    color: var(--primary-color);
}

.password-input-wrapper .form-control {
    padding-right: 45px;
}

/* Autocomplete Suggestions */
#customer_suggestions,
.goods-suggestions {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
    background: #fff;
    margin-top: 2px;
}

#customer_suggestions .list-group-item,
.goods-suggestions .list-group-item {
    border: none;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    padding: 0.75rem 1rem;
}

#customer_suggestions .list-group-item:hover,
.goods-suggestions .list-group-item:hover {
    background-color: #f8f9fa;
}

#customer_suggestions .list-group-item:last-child,
.goods-suggestions .list-group-item:last-child {
    border-bottom: none;
}

.goods-item-row {
    position: relative;
}

.goods-item-row .col-md-6 {
    position: relative;
}

/* Customer Details Row Styles */
.customer-details-row {
    background-color: #f8f9fa !important;
}

.customer-details-row td {
    border-top: 2px solid #dee2e6;
    padding: 0 !important;
}

.customer-details-row .p-3 {
    padding: 1rem !important;
}

.view-customer-details {
    color: var(--primary-color);
    text-decoration: none;
    transition: transform 0.2s ease;
}

.view-customer-details:hover {
    color: var(--primary-dark);
    transform: scale(1.1);
}

.view-customer-details i {
    transition: transform 0.2s ease;
}

.customer-details-row table {
    margin-top: 0.5rem;
    background-color: #fff;
}

.customer-details-row table th {
    background-color: #f8f9fa;
    font-weight: 600;
    font-size: 0.875rem;
}
