/* ============================================
   GROCER PRODUCTION SYSTEM - PREMIUM DESIGN
   Complete Design System with Responsive & RTL Support
   ============================================ */

/* === CSS VARIABLES === */
:root {
    /* Colors */
    --black: #1A1A1A;
    --gold: #C9A962;
    --cream: #F5F3F0;
    --ivory: #FAF9F7;
    --emerald: #2E7D5A;
    --terracotta: #C4785A;
    --gray: #8B8680;
    --light-gold: #E8DFC8;
    --blue: #4A6FA5;
    --purple: #7B6BA8;

    /* System */
    --border: #E0DDD7;
    --radius: 12px;
    --safe-bottom: env(safe-area-inset-bottom, 16px);

    /* Legacy support */
    --grocer-black: #1A1A1A;
    --grocer-gold: #C9A962;
    --grocer-cream: #F5F3F0;
    --grocer-ivory: #FAF9F7;
    --grocer-emerald: #2E7D5A;
    --grocer-terracotta: #C4785A;
    --grocer-gray: #8B8680;
    --grocer-light-gold: #E8DFC8;
    --grocer-blue: #4A6FA5;
    --grocer-purple: #7B6BA8;
}

/* === BASE RESET === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* === TYPOGRAPHY === */
body {
    font-family: 'Plus Jakarta Sans', 'Noto Sans Arabic', sans-serif;
    background: var(--cream);
    color: var(--black);
    min-height: 100vh;
    line-height: 1.6;
}

body.ltr {
    direction: ltr;
}

body.rtl {
    direction: rtl;
}

h1,
h2,
h3,
.headline {
    font-family: 'DM Serif Display', serif;
    letter-spacing: -0.02em;
}

/* === SCREEN MANAGEMENT === */
.screen {
    display: none;
    min-height: 100vh;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* === CENTERED SCREEN (Login) === */
.centered {
    background: linear-gradient(135deg, var(--black) 0%, #2D2D2D 100%);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* === CARD COMPONENT === */
.card {
    background: var(--ivory);
    border-radius: 20px;
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

@media(min-width: 768px) {
    .card {
        padding: 40px 36px;
        max-width: 440px;
    }
}

/* === LOGO === */
.logo {
    text-align: center;
    margin-bottom: 28px;
}

.logo-text {
    font-size: 38px;
    font-family: 'DM Serif Display', serif;
    color: var(--black);
}

.tagline {
    font-size: 11px;
    color: var(--gray);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 4px;
}

/* === FORMS === */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 6px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    font-family: inherit;
    border: 2px solid var(--light-gold);
    border-radius: 10px;
    background: white;
    color: var(--black);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--gold);
}

/* === BUTTONS === */
.btn {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.15s;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-gold {
    background: var(--gold);
    color: var(--black);
}

.btn-emerald {
    background: var(--emerald);
    color: white;
}

.btn-terracotta {
    background: var(--terracotta);
    color: white;
}

.btn-blue {
    background: var(--blue);
    color: white;
}

.btn-purple {
    background: var(--purple);
    color: white;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 11px;
    width: auto;
    border-radius: 6px;
}

/* === ERROR MESSAGES === */
.error-msg {
    background: rgba(196, 120, 90, 0.15);
    border: 1px solid var(--terracotta);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 16px;
    color: var(--terracotta);
    font-size: 13px;
    text-align: center;
    display: none;
}

.error-msg.show {
    display: block;
}

.validation-summary-errors {
    background: rgba(196, 120, 90, 0.15);
    border: 1px solid var(--terracotta);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 16px;
    color: var(--terracotta);
    font-size: 13px;
    text-align: center;
}

/* === HEADER === */
.header {
    background: var(--black);
    padding: 14px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-back,
.btn-logout {
    background: transparent;
    border: 1px solid rgba(201, 169, 98, 0.4);
    color: var(--gold);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-back:hover,
.btn-logout:hover {
    background: rgba(201, 169, 98, 0.1);
    border-color: var(--gold);
}

.lang-toggle {
    background: rgba(201, 169, 98, 0.2);
    border: none;
    color: var(--gold);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-toggle:hover {
    background: rgba(201, 169, 98, 0.3);
}

.header-info {
    flex: 1;
    min-width: 0;
}

body.rtl .header-info {
    text-align: right;
}

body.ltr .header-info {
    text-align: left;
}

.header-title {
    color: var(--gold);
    font-size: 15px;
    font-family: 'DM Serif Display', serif;
}

.header-meta {
    color: var(--gray);
    font-size: 11px;
    margin-top: 2px;
}

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 10px;
    margin-inline-end: 8px;
}

.badge-prod {
    background: var(--emerald);
    color: white;
}

.badge-disp {
    background: var(--terracotta);
    color: white;
}

.badge-admin {
    background: var(--gold);
    color: var(--black);
}

.user-role-badge {
    background: var(--cream);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--gold);
    border: 1px solid var(--light-gold);
    display: inline-block;
}

/* === CONTENT AREA === */
.content {
    flex: 1;
    padding: 16px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.content.with-actions {
    padding-bottom: calc(90px + var(--safe-bottom));
}

@media(min-width: 768px) {
    .content {
        padding: 24px;
    }
}

/* === MENU GRIDS === */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

@media(min-width: 768px) {
    .menu-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

.menu-card {
    background: white;
    border-radius: 16px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.menu-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.menu-card:active {
    transform: scale(0.98);
}

.menu-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.menu-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 4px;
}

.menu-desc {
    font-size: 11px;
    color: var(--gray);
}

/* === SUBMENU GRIDS === */
.submenu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

@media(min-width: 768px) {
    .submenu-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.submenu-card {
    background: white;
    border-radius: 12px;
    padding: 20px 12px;
    text-align: center;
    cursor: pointer;
    border: 2px solid var(--light-gold);
    transition: all 0.2s;
}

.submenu-card:hover {
    border-color: var(--gold);
    background: rgba(201, 169, 98, 0.05);
}

.submenu-card:active {
    transform: scale(0.97);
}

.submenu-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.submenu-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--black);
}

/* === FILTERS === */
.filter-section {
    margin-bottom: 14px;
}

.filter-label {
    font-size: 11px;
    color: var(--gray);
    margin-bottom: 8px;
}

.filter-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-scroll::-webkit-scrollbar {
    display: none;
}

.filter-pill {
    padding: 8px 14px;
    border-radius: 100px;
    border: 2px solid var(--light-gold);
    background: white;
    color: var(--gray);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s;
}

.filter-pill.active {
    border-color: var(--gold);
    background: var(--gold);
    color: var(--black);
}

.filter-pill:hover:not(.active) {
    border-color: var(--gold);
}

/* === PROGRESS CARD === */
.progress-card {
    background: white;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
}

.progress-count {
    color: var(--emerald);
    font-weight: 600;
}

.progress-bar {
    height: 6px;
    background: var(--light-gold);
    border-radius: 100px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--emerald);
    border-radius: 100px;
    transition: width 0.3s;
}

/* === SEARCH === */
.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.search-input {
    flex: 1;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    border: none;
    border-radius: 10px;
    background: white;
    color: var(--black);
    outline: none;
}

/* === ITEM CARDS === */
.item-card {
    background: white;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}

.item-code {
    background: var(--cream);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--gray);
}

.item-details {
    flex: 1;
    min-width: 0;
}

body.rtl .item-details {
    text-align: right;
}

body.ltr .item-details {
    text-align: left;
}

.item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--black);
    line-height: 1.3;
}

.item-category {
    font-size: 10px;
    color: var(--gray);
    margin-top: 2px;
}

/* === ITEM ROWS === */
.item-row {
    display: grid;
    gap: 10px;
    align-items: center;
}

.item-row-2 {
    grid-template-columns: 1fr 1fr;
}

.item-row-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.item-row-4 {
    grid-template-columns: 1fr 1fr auto 1fr;
}

/* === INPUT GROUPS === */
.input-group {
    text-align: center;
}

.input-label {
    font-size: 9px;
    color: var(--gray);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.value-display {
    font-size: 22px;
    font-weight: 700;
    color: var(--black);
    font-family: 'DM Serif Display', serif;
}

.value-sm {
    font-size: 15px;
    font-weight: 600;
    color: var(--black);
    background: var(--cream);
    padding: 6px;
    border-radius: 6px;
}

.value-produced {
    color: var(--emerald);
}

/* === QUANTITY INPUTS === */
.qty-input {
    width: 100%;
    max-width: 80px;
    padding: 10px 6px;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    border: 2px solid var(--light-gold);
    border-radius: 8px;
    background: white;
    color: var(--black);
    outline: none;
    font-family: inherit;
    transition: all 0.2s;
}

.qty-input:focus {
    border-color: var(--gold);
}

.qty-input.filled {
    border-color: var(--emerald);
    background: rgba(46, 125, 90, 0.08);
}

.qty-input.over {
    border-color: var(--terracotta);
    background: rgba(196, 120, 90, 0.08);
}

/* === STORE INPUTS === */
.store-inputs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.store-group {
    text-align: center;
}

.store-label {
    font-size: 10px;
    color: var(--gray);
    margin-bottom: 4px;
}

.store-planned {
    font-size: 9px;
    color: var(--gray);
    margin-bottom: 4px;
}

.store-row {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
}

/* === NOTES INPUT === */
.notes-input {
    width: 100%;
    padding: 10px;
    font-size: 12px;
    font-family: inherit;
    border: 1px solid var(--light-gold);
    border-radius: 8px;
    background: white;
    color: var(--black);
    outline: none;
    margin-top: 10px;
    transition: border-color 0.2s;
}

.notes-input:focus {
    border-color: var(--gold);
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
}

/* === ACTION BAR === */
.action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px 16px;
    padding-bottom: calc(14px + var(--safe-bottom));
    background: linear-gradient(transparent, var(--cream) 25%);
    display: flex;
    gap: 10px;
    justify-content: center;
    z-index: 50;
}

.action-btn {
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    flex: 1;
    max-width: 160px;
    transition: transform 0.15s;
}

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

/* === COPY BUTTON === */
.btn-copy {
    background: var(--blue);
    color: white;
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

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

/* === ADMIN SECTIONS === */
.admin-section {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 14px;
}

.admin-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--black);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* === UPLOAD ZONE === */
.upload-zone {
    border: 2px dashed var(--light-gold);
    border-radius: 12px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-zone:hover {
    border-color: var(--gold);
}

.upload-zone:active {
    border-color: var(--emerald);
    background: rgba(46, 125, 90, 0.05);
}

.upload-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.upload-text {
    font-size: 13px;
    color: var(--black);
}

.upload-hint {
    font-size: 11px;
    color: var(--gray);
    margin-top: 4px;
}

.file-input {
    display: none;
}

.file-info {
    background: rgba(46, 125, 90, 0.1);
    border-radius: 8px;
    padding: 10px;
    margin-top: 12px;
    text-align: center;
    display: none;
}

.file-info.show {
    display: block;
}

.file-name {
    color: var(--emerald);
    font-weight: 600;
    font-size: 12px;
}

/* === STATISTICS === */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.stat-card {
    background: var(--cream);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--black);
    font-family: 'DM Serif Display', serif;
}

.stat-label {
    font-size: 10px;
    color: var(--gray);
    margin-top: 4px;
}

/* === LEGACY ADMIN LAYOUT === */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--black);
    color: white;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
}

.logo-section {
    text-align: center;
    margin-bottom: 50px;
}

.logo-main {
    font-family: 'DM Serif Display', serif;
    font-size: 2rem;
    color: var(--gold);
    text-transform: uppercase;
}

.logo-tag {
    font-size: 0.7rem;
    color: var(--gray);
    letter-spacing: 3px;
    margin-top: 5px;
}

.nav-section-title {
    font-size: 0.75rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 30px 0 15px 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 18px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-link span {
    font-size: 1.2rem;
}

.nav-link:hover {
    background: rgba(201, 169, 98, 0.1);
    color: var(--gold);
    transform: translateX(5px);
}

.nav-link.active {
    background: linear-gradient(90deg, var(--gold) 0%, #B09456 100%);
    color: var(--black);
    box-shadow: 0 4px 15px rgba(201, 169, 98, 0.3);
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.top-bar {
    background: white;
    padding: 15px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.user-snippet {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
}

.content-body {
    padding: 40px;
    flex: 1;
}

/* === PREMIUM COMPONENTS === */
.card-premium {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border);
    margin-bottom: 30px;
}

.btn-premium {
    background: var(--black);
    color: var(--gold);
    border: none;
    padding: 12px 25px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-premium:hover {
    background: var(--gold);
    color: var(--black);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(201, 169, 98, 0.3);
}

/* === TABLES === */
.table-premium {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
}

.table-premium th {
    text-align: left;
    padding: 15px 20px;
    color: var(--gray);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.table-premium tr td {
    background: white;
    padding: 20px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.table-premium tr td:first-child {
    border-left: 1px solid var(--border);
    border-top-left-radius: 15px;
    border-bottom-left-radius: 15px;
}

.table-premium tr td:last-child {
    border-right: 1px solid var(--border);
    border-top-right-radius: 15px;
    border-bottom-right-radius: 15px;
}

/* === UTILITY CLASSES === */
.tech-font {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

.sku-label {
    background: var(--black);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-block;
}

/* === RESPONSIVE GRID === */
.items-grid {
    /* Single column by default (mobile) */
}

@media(min-width: 1024px) {
    .items-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .items-grid .item-card {
        margin-bottom: 0;
    }
}

/* === MOBILE OPTIMIZATIONS === */
@media(max-width: 767px) {
    .header-title {
        font-size: 13px;
    }

    .header-meta {
        font-size: 10px;
    }

    .menu-card {
        padding: 20px 12px;
    }

    .menu-icon {
        font-size: 32px;
    }

    .store-inputs {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .item-row-4 {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .qty-input {
        max-width: 100%;
    }
}

/* === SIDEBAR TOGGLE & MOBILE ADMIN === */
.sidebar-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

.sidebar-toggle span {
    display: block;
    width: 25px;
    height: 2px;
    background: var(--black);
    transition: all 0.3s;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(4px);
}

@media (max-width: 1024px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: -300px;
        z-index: 1000;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        width: 280px;
    }

    /* RTL Support for Sidebar */
    .rtl .sidebar {
        left: auto;
        right: -300px;
    }

    .sidebar-active .sidebar {
        left: 0;
    }

    .rtl.sidebar-active .sidebar {
        right: 0;
    }

    .sidebar-active .sidebar-overlay {
        display: block;
    }

    .top-bar {
        padding: 10px 20px;
    }

    .content-body {
        padding: 20px;
    }

    /* Animate Hamburger */
    .sidebar-active .sidebar-toggle span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .sidebar-active .sidebar-toggle span:nth-child(2) {
        opacity: 0;
    }

    .sidebar-active .sidebar-toggle span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }
}