@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --sb-green: #006241;        /* Starbucks Green */
    --sb-accent: #00754A;       /* Green Accent */
    --sb-house: #1E3932;       /* House Green */
    --sb-warm: #f2f0eb;         /* Neutral Warm */
    --sb-ceramic: #edebe9;      /* Ceramic */
    --sb-text-main: rgba(0, 0, 0, 0.87);
    --sb-text-soft: rgba(0, 0, 0, 0.58);
    --sb-white: #ffffff;
    --sb-shadow: 0 0 0.5px rgba(0,0,0,0.14), 0 1px 1px rgba(0,0,0,0.24);
}

/* --- CUSTOM SCROLLBARS --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--sb-warm);
    color: var(--sb-text-main);
    letter-spacing: -0.01em;
    overflow-y: scroll;
}

h1, h2, h3, h4, h5, h6, .action-btn, .sidebar-link, .category-name, .portal-header h1, .header-left h1, .tray-header h2 {
    font-family: 'Inter', sans-serif;
    color: var(--sb-green);
}

.hidden {
    display: none !important;
}

/* --- FORM FOCUS RINGS --- */
input:focus, textarea:focus {
    outline: none;
    border-color: var(--sb-accent) !important;
    box-shadow: 0 0 0 3px rgba(0, 117, 74, 0.3);
}

.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    padding: 2rem;
}

.auth-card {
    background: var(--sb-white);
    padding: 2rem;
    border-radius: 12px;
    width: min(420px, 100%);
    box-shadow: var(--sb-shadow);
}

.auth-card h1 {
    margin-top: 0;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.auth-field input {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.auth-error {
    color: #d32f2f;
    margin-top: 10px;
}

.portal-screen {
    padding: 2rem;
}

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

.portal-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 2rem;
}

.portal-card {
    background: var(--sb-white);
    padding: 1rem 1.1rem;
    border-radius: 12px;
    box-shadow: var(--sb-shadow);
    border: 1px solid #e2e8f0;
}

.portal-section {
    background: var(--sb-white);
    padding: 1rem 1.1rem;
    border-radius: 12px;
    box-shadow: var(--sb-shadow);
    border: 1px solid #e2e8f0;
    margin-bottom: 1rem;
}

.category-browser {
    padding: 1.5rem 2rem 0;
}

.category-browser-header {
    margin-bottom: 1rem;
}

.category-tiles {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.category-tile {
    background: var(--sb-white);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    text-align: left;
    box-shadow: var(--sb-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.category-name {
    font-weight: 600;
}

.category-cta {
    color: var(--sb-accent);
    font-weight: 600;
}

.saved-emails-list,
.catalogs-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.saved-email-card,
.catalog-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border: 1px solid #eee;
    padding: 0.75rem;
    border-radius: 8px;
}

.catalog-group {
    padding: 0.5rem 0;
}

.catalog-group h3 {
    margin: 0 0 0.5rem 0;
}

.saved-email-title,
.catalog-title {
    font-weight: bold;
}

.saved-email-meta,
.catalog-meta,
.muted {
    color: #777;
    font-size: 0.85rem;
}

.order-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.order-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.order-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border: 1px solid #eee;
    padding: 0.75rem;
    border-radius: 8px;
}

.order-row input {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.order-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

/* --- APP LAYOUT --- */
.app-layout {
    display: flex;
    height: calc(100vh - 70px);
    overflow: hidden;
    background: #f1f5f9;
}

header {
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    background: var(--sb-house);
    color: white;
    z-index: 100;
}

.header-right {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.header-right input {
    padding: 0.6rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 99px;
    width: 300px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--sb-white);
    border-right: 1px solid #e2e8f0;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.sidebar h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--slate);
    margin-bottom: 0.75rem;
}

.sidebar-link {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-radius: 50px;
    border: none;
    background: transparent;
    color: var(--sb-text-main);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.sidebar-link:hover {
    background: var(--sb-ceramic);
}

.sidebar-link.active {
    background: var(--sb-house);
    color: white;
}

.category-links {
    display: flex;
    flex-direction: column;
}

/* --- MAIN CONTENT & GRID --- */
.main-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2rem;
    background: var(--sb-warm);
}

.grid-header {
    margin-bottom: 2rem;
}

.grid-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.grid-header p {
    color: var(--slate);
    font-size: 0.9rem;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

/* --- PRODUCT CARDS (REPSPARK STYLE) --- */
.product-card {
    background: var(--sb-white);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    box-shadow: var(--sb-shadow);
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

.product-card .card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.product-card:hover .card-actions {
    opacity: 1;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    color: var(--ink);
    border: 1px solid #e2e8f0;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: all 0.15s ease;
}

.icon-btn:active {
    transform: scale(0.92);
}

.icon-btn.danger-hover:hover {
    background: #fee2e2;
    color: #ef4444;
    border-color: #fca5a5;
}


.add-btn-static {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--sb-accent);
    color: white;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: all 0.15s ease;
}

.add-btn-static:hover {
    background: var(--sb-green);
}
.add-btn-static:active {
    transform: scale(0.95);
}

.picker-img-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
}

.picker-img-card:hover {
    border-color: var(--accent-2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.product-image {
    width: 100%;
    height: 220px;
    object-fit: contain;
    background: #fff;
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.product-info {
    padding: 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-code {
    font-size: 0.7rem;
    color: var(--slate);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.product-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
    flex-grow: 1;
}

.product-category {
    font-size: 0.7rem;
    color: var(--slate);
    margin-bottom: 0.5rem;
    display: block;
    background: none;
    padding: 0;
}

.product-price {
    font-weight: 700;
    color: var(--ink);
    font-size: 1rem;
}

/* --- RIGHT TRAY --- */
.flier-tray {
    width: 320px;
    flex-shrink: 0;
    background: var(--sb-white);
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
}

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

.tray-header h2 {
    font-size: 1.1rem;
    margin: 0;
}

.badge {
    background: var(--sb-accent);
    color: white;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 700;
}

.tray-items-list {
    flex-grow: 1;
    overflow-y: auto;
    margin: 1rem 0;
}

.full-width {
    width: 100%;
}


.qty-badge {
    font-weight: bold;
}

.qty-ok { color: green; }
.qty-low { color: orange; }
.qty-out { color: red; }

/* --- GLASSMORPHISM MODAL --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    transition: opacity 0.2s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--sb-white);
    width: 80%;
    max-width: 800px;
    height: 80%;
    padding: 2rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255,255,255,0.2);
}

#email-preview-frame {
    flex-grow: 1;
    border: 1px solid #ddd;
    background: #fff;
    overflow-y: auto;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.muted {
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 500;
}


.action-btn {
    padding: 0.55rem 1rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    background-color: var(--sb-ceramic);
    color: var(--sb-text-main);
    transition: all 0.15s ease;
}

.action-btn:active {
    transform: scale(0.95);
}

.action-btn.primary { background-color: var(--sb-accent); color: white; }
.action-btn.danger { background-color: #ef4444; color: white; }

/* --- FLIER ITEM SIZES --- */
.flier-item {
    background: var(--sb-warm);
    border: 1px solid #e2e8f0;
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.flier-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flier-item-title {
    font-weight: 700;
    font-size: 0.9rem;
}

.remove-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    transition: transform 0.15s ease;
}
.remove-btn:hover {
    transform: scale(1.2);
}

.flier-item-price-row {
    display: flex;
    gap: 8px;
}

.price-input-group {
    flex: 1;
}

.price-input-group label {
    display: block;
    font-size: 0.7rem;
    color: var(--slate);
    margin-bottom: 2px;
}

.price-input-group input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.flier-item-sizes {
    margin-top: 5px;
    padding-top: 8px;
    border-top: 1px dashed #e2e8f0;
}

.flier-item-sizes label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--slate);
    margin-bottom: 4px;
    display: block;
}

.size-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.size-option {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7rem;
    cursor: pointer;
    background: white;
    padding: 1px 4px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

.size-option input {
    margin: 0;
    cursor: pointer;
}

/* --- INVENTORY MANAGER STYLES --- */
.inventory-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.inventory-item {
    background: var(--sb-white);
    border: 1px solid #e2e8f0;
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.inventory-item:hover {
    border-color: var(--accent-2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.inventory-item.deleted {
    opacity: 0.5;
    background: #f1f5f9;
}

.inv-info strong {
    font-size: 1.1rem;
    color: var(--ink);
}

.inv-actions {
    display: flex;
    gap: 0.5rem;
}

.edit-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.edit-form label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--slate);
}

.edit-form input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.flier-section textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    min-height: 80px;
    resize: vertical;
    transition: all 0.2s ease;
}

/* --- STYLIZED EMPTY STATES --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--slate);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    color: #cbd5e1;
}

.empty-state h3 {
    margin: 0 0 0.5rem 0;
    color: var(--ink);
}

.empty-state p {
    margin: 0;
    font-size: 0.9rem;
    max-width: 250px;
}

/* --- DRAG & DROP UPLOAD --- */
.drop-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    background: #f8fafc;
    transition: all 0.2s;
    cursor: pointer;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.drop-zone:hover, .drop-zone--over {
    border-color: var(--accent-2);
    background: #f0f9ff;
}

.drop-zone__prompt {
    font-weight: 600;
    color: var(--slate);
    font-size: 0.9rem;
}

.drop-zone svg {
    width: 32px;
    height: 32px;
    color: #94a3b8;
}

/* --- RESPONSIVE LAYOUT (MEDIA QUERIES) --- */
@media (max-width: 1100px) {
    .app-layout {
        flex-direction: column;
        overflow-y: auto;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 250px;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .sidebar-section {
        flex: 1;
        min-width: 200px;
    }
    
    .main-content {
        overflow-y: visible;
        flex-grow: 1;
    }
    
    .flier-tray {
        width: 100%;
        border-left: none;
        border-top: 1px solid #e2e8f0;
        height: auto;
    }
}

/* Inventory levels for email preview - Hidden by default, shown via class */
#email-preview-frame .inventory-level {
    display: none;
    background: #fef08a;
    color: #854d0e;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 4px;
    margin-top: 4px;
    font-weight: bold;
    text-align: center;
}

#email-preview-frame.show-inventory .inventory-level {
    display: block !important;
}
