/* ============================================================================
   CSS VARIABLES (DESIGN TOKENS)
   ============================================================================ */
:root {
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --primary-red: #e63946;
    --accent-black: #1a1a1a;
    --text-main: #333;
    --border-color: #eee;
    --status-new: #ffca3a;
    --status-active: #2a9d8f;
    --status-denied: #e63946;
}


/* ============================================================================
   BASE STYLES & RESETS
   ============================================================================ */

/* Default body styling - applies to all pages */
body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

/* Heading styles */
h2 {
    margin-top: 0;
    color: #1a1a1a;
    text-align: center;
    margin-bottom: 1.5rem;
}


/* ============================================================================
   PAGE-SPECIFIC BODY STYLES
   ============================================================================ */

/* Login page: centered content with fixed viewport height */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 0;
}

/* Dashboard page: scrollable content with flexible height */
body.dashboard-page {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    display: block;
    justify-content: initial;
    align-items: initial;
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}


/* ============================================================================
   LOADING OVERLAY
   ============================================================================ */

/* Full-screen loading spinner overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#loading-overlay img {
    width: 80px;
    height: 80px;
}


/* ============================================================================
   LOGIN PAGE COMPONENTS
   ============================================================================ */

/* Main login card container */
.login-container {
    background-color: #ffffff;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 380px;
}


/* ============================================================================
   FORM COMPONENTS (SHARED)
   ============================================================================ */

/* Form group spacing */
.form-group {
    margin-bottom: 1.2rem;
}

/* Form labels */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #555;
}

/* Text and password inputs */
input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

/* Input focus state */
input:focus {
    outline: none;
    border-color: #4A90E2;
}

/* Primary button styling */
button {
    width: 100%;
    padding: 12px;
    background-color: #4A90E2;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 0.5rem;
}

button:hover {
    background-color: #357ABD;
}

/* Footer text and links */
.footer-text {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: #777;
}

.footer-text a {
    color: #4A90E2;
    text-decoration: none;
}


/* ============================================================================
   DASHBOARD LAYOUT
   ============================================================================ */

/* Main dashboard container - centers content with max width */
.dashboard-container {
    max-width: 1100px;
    margin: 0 auto;
}

/* Dashboard header with title and options button */
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.dash-header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--accent-black);
}

/* Options/Settings button in header */
.options-btn {
    background-color: var(--accent-black);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s;
}

.options-btn:hover {
    opacity: 0.8;
}


/* ============================================================================
   DROPDOWN MENU
   ============================================================================ */

/* Container that positions the dropdown relative to the button */
.options-wrapper {
    position: relative;
    display: inline-block;
}

/* The dropdown menu itself - toggled by JavaScript */
.dropdown-box {
    display: none;
    position: absolute;
    top: calc(100% + 8px); /* 8px below the button */
    right: 0; /* Aligned to right edge of button */
    width: 200px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
}

/* Dropdown menu items */
.dropdown-box a {
    display: block;
    padding: 12px 15px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

.dropdown-box a:last-child {
    border-bottom: none;
}

.dropdown-box a:hover {
    background: #f8f9fa;
    color: var(--accent-black);
}


/* ============================================================================
   SECTION CARDS
   ============================================================================ */

/* Card wrapper for dashboard sections */
.section-card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 40px;
    overflow: hidden;
    overflow-x: auto; /* Horizontal scroll for wide content like long emails */
}

/* Section header with title */
.section-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-header h2 {
    margin: 0;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
}


/* ============================================================================
   TABLES
   ============================================================================ */

/* Table base styling */
table {
    width: 100%;
    border-collapse: collapse;
}

/* Table cells - allow long text to wrap */
th,
td {
    overflow-wrap: anywhere;
    word-break: break-word;
}

td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

/* Status badges (can be used in tables or elsewhere) */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
}

.bg-new {
    background-color: var(--status-new);
    color: #000;
}

.bg-active {
    background-color: var(--status-active);
}

.bg-denied {
    background-color: var(--status-denied);
}

/* Action links in tables */
.action-link {
    color: var(--primary-red);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
}


/* ============================================================================
   MODAL OVERLAY & CONTENT
   ============================================================================ */

/* Full-screen modal background overlay */
#modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

/* Modal content box */
#modal-content {
    background: #fff;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    position: relative;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Modal close button */
#modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    z-index: 10;
}

#modal-close:hover {
    color: #333;
}

/* Modal stack for nested content */
#modal-stack {
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

/* Individual modal layers with slide-in animation */
.modal-layer {
    width: 100%;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ============================================================================
   IMAGE LIGHTBOX
   ============================================================================ */

/* Full-screen image viewer (generic) */
.fullscreen-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    cursor: zoom-out;
    justify-content: center;
    align-items: center;
}

.fullscreen-lightbox img {
    max-width: 95%;
    max-height: 95%;
    border: 3px solid white;
}

/* Specific image lightbox overlay - higher z-index than main modal */
#image-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10001;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
}

/* Image inside lightbox */
#lightbox-img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 4px;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
    border: 3px solid white;
}

/* Optional lightbox close button */
#lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}


/* ============================================================================
   CONTACT/USER INFORMATION DISPLAY
   ============================================================================ */

/* Contact header section */
.contact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 2px solid #eaeaea;
    margin-bottom: 20px;
    border-radius: 8px 8px 0 0;
}

/* User info section within contact header */
.user-info h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #222;
}

.user-info p {
    margin: 5px 0 0;
    color: #666;
    font-size: 0.95rem;
}

/* Shopify verified badge */
.display_shopify_verified {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #e7f3ff;
    color: #007ace;
    padding: 6px 14px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid #cde4ff;
}

/* File count indicator badge */
.file-count-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffeb6b;
    color: #ff4f00;
    padding: 6px 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid #cde4ff;
}

/* Alternative badge styling for contact view */
.contact-header .badge {
    background: #e1f5fe;
    color: #0288d1;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
}

/* Divider line */
.divider {
    border: 0;
    border-top: 1px solid #eee;
    margin: 20px 0;
}


/* ============================================================================
   BUSINESS/LOCATION CARDS
   ============================================================================ */

/* Individual business card in grid */
.business-grid {
    width: 300px;
    float: left;
    margin: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease;
}

.business-grid:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

/* Image at the top of the business card */
.business-image img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
    cursor: pointer;
    background: #eee;
}

/* Business card content area */
.business-info {
    padding: 15px;
}

.business-info h3 {
    margin-top: 0;
    font-size: 1.1rem;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.business-info p {
    margin: 8px 0;
    font-size: 0.9rem;
    color: #555;
    line-height: 1.4;
}

.business-info strong {
    color: #111;
    font-weight: 600;
}


/* ============================================================================
   HEADER COMPONENTS
   ============================================================================ */

/* Add button for sections */
.add-btn {
    background-color: var(--primary-red);
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
    transition: background 0.2s;
}

.add-btn:hover {
    background-color: var(--accent-black);
}

/* Header grouping elements */
.header-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Hidden template wrapper */
#templateWrapper {
    display: none;
}

/* Layout for the right side of the header */
.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

/* Button grouping in header - 2-row grid for desktop, columns auto-adjust */
.header-actions {
    display: grid;
    grid-template-rows: 1fr 1fr; /* 2 rows */
    grid-auto-flow: column; /* Fill columns first, then move to next row */
    gap: 6px; /* Tighter spacing */
    max-width: 600px; /* Constrain width to make buttons narrower */
}


/* ============================================================================
   USER FORM CONTAINER
   ============================================================================ */

/* Container for user forms */
.user-form-container {
    max-width: 400px;
    padding: 20px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
}

.user-form-container h3 {
    margin-top: 0;
    color: #333;
}

.user-form-container .form-group {
    margin-bottom: 15px;
}

.user-form-container .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-form-container .form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}


/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */

/* Toast notification that slides down from top */
#toast-notice {
    position: fixed;
    top: -100px; /* Start hidden above the screen */
    left: 50%;
    transform: translateX(-50%);
    min-width: 300px;
    padding: 15px 25px;
    border-radius: 0 0 8px 8px; /* Rounded only on the bottom */
    color: white;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 11000; /* Above everything, including modals */
    transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#toast-notice.success {
    background-color: #28a745;
    border: 1px solid #1e7e34;
}

#toast-notice.error {
    background-color: #dc3545;
    border: 1px solid #bd2130;
}

#toast-notice.show {
    top: 0;
}


/* ============================================================================
   TABS
   ============================================================================ */

/* Tab container */
.tabs-container {
    display: flex;
    gap: 0;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

/* Individual tab button */
.tab-btn {
    background: transparent;
    border: none;
    padding: 15px 30px;
    font-size: 1rem;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    bottom: -2px; /* Overlaps with container border */
}

.tab-btn:hover {
    color: var(--accent-black);
    background: rgba(0, 0, 0, 0.02);
}

.tab-btn.active {
    color: var(--primary-red);
    border-bottom-color: var(--primary-red);
}

/* Tab content panels */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}


/* ============================================================================
   LOCATION COMPONENTS
   ============================================================================ */

/* Wrapper for location cards grid */
#locations-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
}

/* Location action buttons container */
.location-actions {
    display: flex;
    gap: 8px;
    padding: 10px 15px;
    border-top: 1px solid #eee;
    margin-top: 10px;
}

/* Edit location button */
.btn-edit-location {
    flex: 1;
    background: #4A90E2;
    color: white;
    border: 1px solid #357ABD;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-edit-location:hover {
    background: #357ABD;
}

/* Delete location button */
.btn-delete-location {
    flex: 1;
    background: #e63946;
    color: white;
    border: 1px solid #d32f2f;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-delete-location:hover {
    background: #d32f2f;
}


/* ============================================================================
   FORM CONTAINERS (LOCATION & DEALER)
   ============================================================================ */

/* Centered form wrapper */
.centered-form {
    margin: 0 auto;
    max-width: 500px;
}

/* Location form container */
.location-form-container {
    max-width: 500px;
    padding: 20px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
}

.location-form-container h3 {
    margin-top: 0;
    color: #333;
    margin-bottom: 20px;
}

.location-form-container .form-group {
    margin-bottom: 15px;
}

.location-form-container .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.85rem;
}

.location-form-container .form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 0.95rem;
}

.location-form-container .form-group input:focus {
    outline: none;
    border-color: #4A90E2;
}

/* Dealer form container */
.dealer-form-container {
    max-width: 500px;
    padding: 20px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
}

.dealer-form-container h3 {
    margin-top: 0;
    color: #333;
    margin-bottom: 20px;
}

.dealer-form-container .form-group {
    margin-bottom: 15px;
}

.dealer-form-container .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.85rem;
}

.dealer-form-container .form-group input,
.dealer-form-container .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 0.95rem;
}

.dealer-form-container .form-group input:focus,
.dealer-form-container .form-group textarea:focus {
    outline: none;
    border-color: #4A90E2;
}

.dealer-form-container .file-help {
    font-size: 0.8rem;
    color: #666;
    margin-top: 4px;
}


/* ============================================================================
   TWO-COLUMN MODAL LAYOUT
   ============================================================================ */

/* Modal with side-by-side content and notes */
.modal-two-col {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 16px;
    align-items: start;
}

/* Notes panel in modal */
.modal-two-col__notes {
    border-left: 1px solid #e5e5e5;
    padding-left: 16px;
    max-height: 70vh;
    overflow: auto;
}

/* Individual note entry styling */
.modal-two-col__notes .note_entry {
    padding: 10px 12px;
    margin: 0 0 10px 0;
    border-radius: 8px;
    background: #f7f7f7;
}

.modal-two-col__notes .note_entry.public {
    background: #eef7ff;
    border: 1px solid #cfe6ff;
}

.modal-two-col__notes .note_entry.private {
    background: #f7f7f7;
    border: 1px solid #e8e8e8;
}


/* ============================================================================
   NOTES SECTION
   ============================================================================ */

/* Note input textarea */
#note_input_field {
    width: 98%;
    height: 75px;
}

/* Note type and from labels - inline display */
#note_type_sel_label,
#note_from_sel_label {
    display: inline-block;
}

#note_input_wrap label {
    font-size: 10px;
    display: inline;
}


/* ============================================================================
   ACTION BUTTONS
   ============================================================================ */

/* Base button class - 2-column grid layout for desktop */
.btn {
    padding: 6px 12px; /* Reduced height (was 8px 16px) */
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.8rem; /* Slightly smaller text */
    transition: all 0.2s;
    width: auto; /* Allow buttons to be narrower */
}

/* Deny/Delete button - red */
.btn-deny {
    background: #f44336;
    color: white;
    border: 1px solid #d32f2f;
}

.btn-deny:hover {
    background: #d32f2f;
}

/* Approve button - green */
.btn-approve {
    background: #4caf50;
    color: white;
    border: 1px solid #388e3c;
}

.btn-approve:hover {
    background: #388e3c;
}

/* Notes button - yellow/amber */
.btn-notes {
    background: #ffb703;
    color: #1a1a1a;
    border: 1px solid #e09f00;
}

.btn-notes:hover {
    background: #e09f00;
}

/* Ban button - dark gray/black */
.btn-ban {
    background: #2d2d2d;
    color: #ffffff;
    border: 1px solid #1a1a1a;
    transition: background 0.2s ease;
}

.btn-ban:hover {
    background: #1a1a1a;
    color: #e63946; /* Red hint on hover */
    border-color: #e63946;
}
/* Delete user button - dark red/black */
.btn-delete {
    background: #950000;
    color: #ffffff;
    border: 1px solid #1a1a1a;
    transition: background 0.2s ease;
}

.btn-delete:hover {
    background: #1a1a1a;
    color: #e63946; /* Red hint on hover */
    border-color: #e63946;
}

/* Upload link button - blue */
.btn-upload-link {
    background: #007ace;
    color: white;
    border: 1px solid #005fa3;
}

.btn-upload-link:hover {
    background: #005fa3;
}

/* Submit button - full width, blue */
.btn-submit {
    width: 100%;
    padding: 12px;
    background: #007ace;
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
}

.btn-submit:hover {
    background: #005fa3;
}


/* ============================================================================
   RESPONSIVE DESIGN - MOBILE ADJUSTMENTS
   ============================================================================ */

/* Mobile responsive: adjust business cards and contact header */
@media (max-width: 600px) {
    /* Make business cards full width on mobile */
    .business-grid {
        width: 100%;
        float: none;
        margin: 10px 0;
    }

    /* Stack contact header elements vertically */
    .contact-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    /* Adjust header right alignment for mobile */
    .header-right {
        align-items: flex-start;
        width: 100%;
        margin-top: 15px;
    }

    /* Make header actions single column on mobile */
    .header-actions {
        grid-template-columns: 1fr; /* Single column on mobile */
        width: 100%;
        max-width: none;
    }

    /* Buttons grow to fill width on mobile */
    .btn {
        width: 100%;
    }
}

/* Mobile responsive: stack two-column modal layout */
@media (max-width: 768px) {
    .modal-two-col {
        grid-template-columns: 1fr;
    }

    .modal-two-col__notes {
        border-left: 0;
        padding-left: 0;
        border-top: 1px solid #e5e5e5;
        padding-top: 16px;
        max-height: none;
    }
}

/* ============================================================================
      PENDING COUNT BADGE
      ============================================================================ */

.pending_count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    min-width: 15px;
    min-height: 15px;
    background-color: var(--primary-red);
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 0.55rem;
    margin-right: 5px;
    top: -10px;
    position: relative;
}