:root {
    --primary-color: #29805f;
    --primary-hover: #1e6158;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #eb2342;
    --warning-color: #f5ab0b;
    --background-color: #f8fafcc7;
    --card-background: #ffffffc7;
    --gradient-background: linear-gradient(122deg, #23523cba, #013c2fa8);
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 0.5rem;
    --transition: all 0.2s ease-in-out;
    
    /* Bootstrap color overrides */
    --bs-primary: rgb(41, 128, 92);
    --bs-primary-rgb: 41, 128, 92;
    --bs-secondary: #4b5e59;
    --bs-secondary-rgb: 75, 94, 89;
    --bs-success: #3aa87c;
    --bs-success-rgb: 58, 168, 124;
    --bs-danger: #6b2d2a;
    --bs-danger-rgb: 107, 45, 42;
    --bs-warning: #b5a04b;
    --bs-warning-rgb: 181, 160, 75;
    --bs-info: #2f8e8e;
    --bs-info-rgb: 47, 142, 142;
    --bs-link-color: #1a5850;
    --bs-link-color-rgb: 26, 88, 80;
    --bs-link-hover-color: rgb(50, 155, 106);
    --bs-link-hover-color-rgb: 40, 122, 84;

    /* Button states */
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: color-mix(in srgb, var(--bs-primary) 50%, black);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: color-mix(in srgb, var(--bs-primary) 85%, black);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--bs-primary) 80%, black);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: color-mix(in srgb, var(--bs-primary) 70%, black);
    --bs-btn-active-border-color: color-mix(in srgb, var(--bs-primary) 65%, black);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--bs-primary);
    --bs-btn-disabled-border-color: var(--bs-primary);
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Layout base */
html,
body {
    height: auto;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
}

main {
    flex: 1 0 auto;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Sticky header */
.header-bar {
    position: sticky;
    /* stays visible at top while scrolling */
    top: 0;
    z-index: 1000;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 20px 30px;
    /* larger padding at start */
    background: var(--gradient-background);
    color: white;
    transition: padding 0.3s ease, background 0.3s ease;
}
.header-left a {
    text-decoration: none;  /* remove underline from the link entirely */
    color: inherit;          /* let text inside keep its color */
}

.logo {
    height: auto;
    width: 10rem;
    transition: height 0.3s ease;
}

.app-title {
    font-size: 2rem;
    margin: 0;
    font-weight: 600;
    transition: font-size 0.3s ease;
}

.app-subtitle {
    font-size: 1rem;
    margin: 0;
    font-weight: 400;
    opacity: 0.95;
}

/* Header sections */
.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.header-logo-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex: 1 1 auto;
    min-width: 0; /* allow truncation inside when very narrow */
}

.header-right {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    /* flex: 0 0 auto; */
     /* allow nav and user-menu to wrap when space is narrow */
    justify-content: flex-end;
    flex-wrap: wrap;
    align-items: center;
}

.header-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.header-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: white;
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: 500;
    white-space: nowrap;
    font-size: 0.95rem;
}

.header-nav .nav-link:hover,
.header-nav .nav-link:focus {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.header-nav .nav-link.active {
    background: rgba(255, 255, 255, 0.25);
}

.header-nav .nav-link i {
    font-size: 1.1rem;
}

/* Footer always pushed down when content is short */
footer {
    flex-shrink: 0;
    background: var(--gradient-background);
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-top: auto;
}

.payment-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.payment-banner img {
    height: 34px;
    width: auto;
    background: #ffffff;
    border-radius: 6px;
    padding: 4px 6px;
    display: block;
}


/* Messages */
.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--error-color);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.success-message {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: var(--success-color);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

/* User menu */
.user-menu {
    flex-shrink: 0;
    position: relative;
    flex: 0 0 auto;
}

.user-menu::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 8px;
    background: transparent;
    pointer-events: auto;
    z-index: 999;
}

.user-menu .dropdown-menu {
    margin-top: 0.5rem !important;
    z-index: 1000;
    min-width: 180px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color, #e0e0e0);
}

.user-menu .dropdown-item {
    padding: 0.625rem 1rem;
    font-size: 0.9rem;
}

.user-menu .dropdown-item:hover {
    background-color: var(--hover-bg, #f5f5f5);
}

.user-menu .dropdown-item i {
    width: 1.25rem;
    text-align: center;
    font-size: 1.1rem;
}

.user-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: white;
    font-weight: 500;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.user-toggle:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
}

.user-icon {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

.menu-icon {
    font-size: 1.2rem;
    opacity: 0.8;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.user-menu:hover .menu-icon {
    transform: rotate(90deg);
    opacity: 1;
}

.user-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mobile: Disable hover behavior, use click only */
@media (max-width: 768px) {
    main {
        padding: 1rem;
    }

    .logo {
        width: 7.5rem;
        height: auto;
    }

    .app-title {
        font-size: 1.5rem;
    }

    .user-menu .dropdown-menu {
        margin-top: 0.25rem !important;
    }

    .field-group {
        grid-template-columns: 1fr;
    }

    .btn-actions {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        justify-content: center;
    }

    .input-container {
        flex-direction: column;
    }
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: color-mix(in srgb, var(--bs-primary) 50%, black);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: color-mix(in srgb, var(--bs-primary) 85%, black);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--bs-primary) 80%, black);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: color-mix(in srgb, var(--bs-primary) 70%, black);
    --bs-btn-active-border-color: color-mix(in srgb, var(--bs-primary) 65%, black);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--bs-primary);
    --bs-btn-disabled-border-color: var(--bs-primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #475569;
    transform: translateY(-1px);
}

/* Form elements */
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    outline: none;
    border-color: #0c8a4f;
    box-shadow: 0 0 0 0.25rem rgba(43, 184, 153, 0.25);
}

.form-check-input:checked {
    background-color: #0c8a4f;
    border-color: #0c8a4f;
}

.form-text {
    color: #6b7280;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: block;
}

.form-check-input[type=checkbox] {
    padding: 0.6rem;
}

.form-control::placeholder,
input::placeholder {
    color: rgba(108, 116, 125, 0.65);
    font-style: italic;
    opacity: 1; /* Prevents Firefox from applying additional opacity */
}

input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--card-background);
    width: 100%;
    /* always stretch */
    min-width: 0;
    /* allow shrinking properly */
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(20, 173, 97, 0.1);
}

input.invalid {
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Custom modals */
.modal-xl {
    max-width: 95vw !important;
}

.modal-xl .modal-body {
    padding: 1.5rem;
}

.nav-tabs .nav-link {
    border-radius: 0.375rem 0.375rem 0 0;
    color: #495057;
}

.nav-tabs .nav-link.active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: white;
}


.form-label {
    font-weight: 600;
    color: #495057;
}

.form-label i {
    color: #6c757d;
}

#copy-address-btn {
    font-size: 0.875rem;
}

.form-check-label {
    font-size: 0.95rem;
    padding-left: 0.9rem;
}

.tab-pane {
    min-height: 400px;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

.alert {
    margin-bottom: 1rem;
}

/* Footer link styling - always white */
footer a {
    color: #fff !important;
    text-decoration: none;
}

footer a:hover {
    color: #fff !important;
    text-decoration: underline;
}

footer a:visited {
    color: #fff !important;
}

footer a:active {
    color: #fff !important;
}

footer a:focus {
    color: #fff !important;
}

/* Responsive */
@media (max-width: 950px) {
    .modal-lg, .modal-xl {
        --bs-modal-width: 95vw;
    }
}

@media (min-width: 950px) {
    .modal-lg, .modal-xl {
        --bs-modal-width: 900px;
    }
}

@media (max-width: 768px) {
    main {
        padding: 1rem;
    }

    .logo {
        width: 7.5rem;
        height: auto;
    }

    .app-title {
        font-size: 1.5rem;
    }

    .user-menu .dropdown-menu {
        margin-top: 0.25rem !important;
    }

    .field-group {
        grid-template-columns: 1fr;
    }

    .btn-actions {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        justify-content: center;
    }

    .input-container {
        flex-direction: column;
    }
}

/* Even smaller screens (phones) */
@media (max-width: 480px) {
    .logo {
        width: 6rem;
        height: auto;
    }

    .app-title {
        font-size: 1.2rem;
    }

    .user-menu .user-icon {
        font-size: 1.2rem;
    }

    .user-menu .menu-icon {
        font-size: 1rem;
    }

    .header-nav .nav-link {
        padding: 0.375rem;
        min-width: 40px;
    }

    .header-nav .nav-link i {
        font-size: 1rem;
    }

    .user-name {
        max-width: 100px;
    }

    .user-icon {
        font-size: 1.35rem;
    }
}

/* ========================================
   Responsive: Very small screens (< 480px)
   ======================================== */
@media (max-width: 479px) {
    .logo {
        width: 6rem;
        height: auto;
    }

    .app-title {
        font-size: 1.2rem;
    }

    .user-icon {
        font-size: 1.2rem;
    }

    .menu-icon {
        font-size: 1rem;
    }

    .header-nav .nav-link {
        padding: 0.3rem;
        min-width: 36px;
        font-size: 0.85rem;
    }

    .header-nav .nav-link i {
        font-size: 0.95rem;
    }

    .user-name {
        max-width: 80px;
    }

    .user-menu .dropdown-menu {
        min-width: 150px;
        font-size: 0.85rem;
    }

    .user-menu .dropdown-item {
        padding: 0.5rem 0.75rem;
    }
}

/* ========================================
   Responsive: Extra small (< 380px)
   ======================================== */
@media (max-width: 379px) {
    .header-bar {
        padding: 15px 20px;
        gap: 0.75rem;
    }

    .header-logo-title {
        gap: 10px;
    }

    .logo {
        width: 4rem;
    }

    .app-title {
        font-size: 1.2rem;
    }

    .app-subtitle {
        font-size: 0.7rem;
    }

    .header-left {
        flex-basis: 100%;
        gap: 0.5rem;
    }

    .header-nav .nav-link {
        padding: 0.3rem;
        min-width: 36px;
        font-size: 0.85rem;
    }

    .header-nav .nav-link i {
        font-size: 0.95rem;
    }

    .user-name {
        max-width: 80px;
    }

    .user-menu .dropdown-menu {
        min-width: 150px;
        font-size: 0.85rem;
    }

    .user-menu .dropdown-item {
        padding: 0.5rem 0.75rem;
    }
}

/* ========================================
   Responsive: Ultra narrow (< 280px)
   ======================================== */
@media (max-width: 279px) {
    .header-bar {
        padding: 12px 15px;
        gap: 0.5rem;
    }

    .header-logo-title {
        gap: 8px;
    }

    .app-subtitle {
        font-size: 0.65rem;
    }

    .header-nav {
        gap: 0.25rem;
    }

    .header-nav .nav-link {
        padding: 0.25rem;
        min-width: 32px;
        font-size: 0.75rem;
    }

    .header-nav .nav-link i {
        font-size: 0.9rem;
    }

    .user-name {
        max-width: 60px;
    }

    .user-menu .dropdown-menu {
        min-width: 150px;
        font-size: 0.85rem;
    }

    .user-menu .dropdown-item {
        padding: 0.5rem 0.75rem;
    }
}

/* ========================================
   Responsive: Minimum viable (250px)
   ======================================== */
@media (max-width: 259px) {
    .header-left a > div {
        gap: 0.125rem;
    }

    .logo {
        width: 2.8rem;
    }

    .app-title {
        font-size: 0.65rem;
        letter-spacing: -0.025em;
    }

    .user-toggle {
        padding: 0.25rem;
    }

    .user-icon {
        font-size: 1rem;
    }

    .menu-icon {
        font-size: 0.7rem;
    }

    .user-name {
        max-width: 50px;
        font-size: 0.7rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0.01ms !important;
    }
}

/* Footer links - prevent line breaks between icon and text */
footer p a {
    display: inline-flex;
    align-items: baseline;
    white-space: nowrap;
    gap: 0.4rem; /* replaces me-1 */
}

footer p a i {
    font-size: 1.1em;
    flex-shrink: 0;
}

/* Optional: Responsive adjustments for very narrow screens */
@media (max-width: 480px) {
    footer p {
        font-size: 0.9rem;
        letter-spacing: -0.01em;
    }
    
    footer p a {
        gap: 0.3rem;
    }
}