/* ============================================
   POS 3M Generator - Tool-Specific Styles
   Imports shared design-system.css from root
   ============================================ */

@import url('../../css/design-system.css');

/* --- Material Symbols Fix --- */
.material-symbols-rounded { font-family: 'Material Symbols Rounded'; }

/* --- POS 3M Color Overrides --- */
:root {
    --md-primary: #e05547;
    --md-primary-light: #f06b5e;
    --md-primary-container: #ffeee9;
    --md-on-primary: #ffffff;
    --md-on-primary-container: #8c1a0e;
    --bg: #fffaf9;
}

body { background-color: var(--bg); }

.top-bar { background: rgba(255,250,249,0.88); border-bottom-color: rgba(224,85,71,0.12); }

.filled-button { background-color: var(--md-primary); }
.filled-button:hover { box-shadow: 0 8px 24px rgba(224,85,71,0.22); }
.filled-button:disabled { background-color: var(--md-outline-variant); }

.tabs__tab--active { color: var(--md-primary); border-bottom-color: var(--md-primary); }
.tabs__tab:hover { background: rgba(224,85,71,0.04); }

.search-bar:focus-within { border-color: var(--md-primary); box-shadow: 0 0 0 3px rgba(224,85,71,0.1); }
.search-bar__match-indicator.matched { background-color: var(--md-primary); }

.data-table__th--sortable:hover { color: var(--md-primary); }
.data-table__th--sortable.sort-asc .sort-icon,
.data-table__th--sortable.sort-desc .sort-icon { color: var(--md-primary); }

.data-table__action-btn--edit { background: #ffeee9; color: #8c1a0e; }
.data-table__action-btn--edit:hover { background: #ffd9d2; }

.scroll-top-btn { background: var(--md-primary); color: var(--md-on-primary); border: none; }
.scroll-top-btn:hover { background: var(--md-primary-light); color: #fff; }

.checkbox__box::after { background: var(--md-primary); }
.checkbox input[type="checkbox"]:checked + .checkbox__box { border-color: var(--md-primary); background: var(--md-primary); }
.checkbox:hover .checkbox__box { border-color: var(--md-primary); }

.form-field__input:focus { border-color: var(--md-primary); box-shadow: 0 0 0 4px rgba(224,85,71,0.12); }

.icon-button--active { background: var(--md-primary-container); color: var(--md-primary); border-color: rgba(224,85,71,0.2); }

.toast--success { background: #188038; }

/* --- Workspace Layout --- */
.workspace {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-top: 24px;
}

.main-content {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.main-content > .empty-state,
.main-content > .workspace {
    width: 100%;
    max-width: 900px;
}

/* --- Card Component --- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--md-shape-xl);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.card__icon {
    font-size: 1.1rem;
    color: var(--md-primary);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--md-primary-container);
    border-radius: var(--md-shape-md);
}

.card__info { flex: 1; min-width: 0; }
.card__title { font-size: 1rem; font-weight: 800; color: var(--ink); }
.card__subtitle { font-size: 0.82rem; color: var(--muted); }
.card__body { padding: 16px 20px; }
.card__table { max-height: 300px; overflow-y: auto; }
.card__table .data-table { font-size: 0.85rem; }
.card__table .data-table__th,
.card__table .data-table__td { padding: 10px 12px; }

/* --- Parameters Grid --- */
.params-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }

/* --- Red Dates + Excluded Row --- */
.red-excluded-row { display: grid; grid-template-columns: auto 1fr; gap: 16px; margin-top: 4px; }
.red-excluded-row .form-field--calendar { min-width: 280px; }
.red-excluded-row .form-field--excluded { min-width: 0; }

/* --- Calendar Picker (compact) --- */
.calendar-picker {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--md-shape-md);
    padding: 8px;
    max-width: 280px;
}

.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.calendar-title { font-size: 0.82rem; font-weight: 700; color: var(--ink); }
.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; margin-bottom: 2px; }
.calendar-weekdays span { font-size: 0.65rem; font-weight: 700; color: var(--muted); padding: 2px 0; text-transform: uppercase; letter-spacing: 0.5px; }
.calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.calendar-day { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 0.72rem; border-radius: 50%; cursor: pointer; transition: all 0.15s; color: var(--ink); font-weight: 500; }
.calendar-day:hover { background: var(--surface-soft); }
.calendar-day--empty { cursor: default; }
.calendar-day--red { background: var(--md-error); color: white; font-weight: 700; }
.calendar-day--red:hover { background: #c62828; }
.calendar-red-count { font-size: 0.72rem; color: var(--muted); text-align: center; padding-top: 6px; }

/* --- Textarea --- */
.form-field__textarea {
    width: 100%;
    height: 100px;
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
    font-family: var(--md-font-family);
    font-size: 1rem;
    color: var(--ink);
    outline: none;
    resize: none;
    transition: all var(--md-motion-duration-short) var(--md-motion-standard);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.form-field__textarea:focus {
    border-color: var(--md-primary);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(224,85,71,0.12);
}

.form-field__textarea::placeholder { color: #9aa0a6; font-family: var(--md-font-family); }
.form-field__helper { font-size: 0.78rem; color: var(--muted); margin-top: 4px; font-weight: 600; }

/* --- Select --- */
select.form-field__input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%235f6368' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
    cursor: pointer;
}

/* --- Generate Section --- */
.generate-section { display: flex; justify-content: center; padding: 8px 0 24px; }
.filled-button--large { height: 52px; padding: 0 36px; font-size: 1rem; }
.filled-button--large i { font-size: 1.1rem; }

/* --- Tonal Button Small --- */
.tonal-button--small { height: 32px; padding: 0 12px; font-size: 0.78rem; }
.tonal-button--small i { font-size: 0.85rem; }

/* --- Preview Table Force Fit --- */
#dialogPreview .dialog__table-container { overflow-x: hidden; }
#dialogPreview .data-table { table-layout: fixed; width: 100%; }
#dialogPreview .data-table th:nth-child(1),
#dialogPreview .data-table td:nth-child(1) { width: 40px; text-align: center; }
#dialogPreview .data-table th:nth-child(2),
#dialogPreview .data-table td:nth-child(2) { width: 90px; }
#dialogPreview .data-table th:nth-child(3),
#dialogPreview .data-table td:nth-child(3) { width: 95px; white-space: nowrap; }
#dialogPreview .data-table th:nth-child(4),
#dialogPreview .data-table td:nth-child(4) { width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dialogPreview .data-table th:nth-child(5),
#dialogPreview .data-table td:nth-child(5) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dialogPreview .data-table th:nth-child(6),
#dialogPreview .data-table td:nth-child(6) { width: 70px; text-align: right; padding-right: 16px; }

/* --- Preview Sort --- */
#dialogPreview .data-table__th--sortable { cursor: pointer; user-select: none; position: relative; padding-right: 22px !important; }
#dialogPreview .data-table__th--sortable:hover { background: var(--surface-soft); }
#dialogPreview .sort-icon { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); font-size: 0.65rem; opacity: 0.4; }
#dialogPreview .data-table__th--sortable:hover .sort-icon { opacity: 0.7; }
#dialogPreview .data-table__th--sortable.sort-asc .sort-icon,
#dialogPreview .data-table__th--sortable.sort-desc .sort-icon { opacity: 1; color: var(--md-primary); }

/* --- Customer/Rasio Dialog Size --- */
#dialogCustomerDb .dialog__container,
#dialogRasioDb .dialog__container { width: min(90vw, 960px); height: min(85vh, 680px); }

/* --- Items Summary Highlight --- */
.items-summary-highlight { color: var(--md-primary); font-weight: 700; }

/* --- Row Highlight for ID00036 --- */
.data-table__body tr.row-id00036 { background-color: #FFF3E0; }
.data-table__body tr.row-id00036:hover { background-color: #FFE0B2; }

/* --- Status Badge --- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.badge--dealer { background: #e8f0fe; color: #1565C0; }
.badge--hotel { background: #e6f4ea; color: #2E7D32; }
.badge--restaurant { background: #fff3e0; color: #E65100; }

/* --- Loading State --- */
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.85); backdrop-filter: blur(8px); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 9999; gap: 16px; }
.loading-overlay__spinner { width: 48px; height: 48px; border: 4px solid var(--line); border-top-color: var(--md-primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay__text { font-size: 0.9rem; color: var(--muted); font-weight: 700; }

/* --- Dropdown --- */
.dropdown { position: relative; }
.dropdown__menu { position: absolute; top: 100%; right: 0; margin-top: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); min-width: 220px; z-index: 300; opacity: 0; pointer-events: none; transform: translateY(-8px); transition: all 0.18s var(--md-motion-standard); padding: 6px; }
.dropdown__menu.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.dropdown__item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: none; background: transparent; color: var(--ink); font-family: var(--md-font-family); font-size: 0.9rem; font-weight: 600; cursor: pointer; text-align: left; border-radius: 12px; transition: background 0.1s; }
.dropdown__item:hover { background: var(--surface-soft); }
.dropdown__item i { font-size: 0.95rem; color: var(--muted); width: 20px; text-align: center; }

/* --- Item Name Cell (wrap + ellipsis) --- */
.item-name-cell { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-name-cell:hover { white-space: normal; overflow: visible; }

/* --- Force Fit Table (items preview) --- */
.card__table { overflow-x: hidden; }
.card__table .data-table { table-layout: fixed; width: 100%; }
.card__table .data-table th:nth-child(1),
.card__table .data-table td:nth-child(1) { width: 50px; }
.card__table .data-table th:nth-child(2),
.card__table .data-table td:nth-child(2) { width: 100px; }
.card__table .data-table th:nth-child(3),
.card__table .data-table td:nth-child(3) { width: auto; }
.card__table .data-table th:nth-child(4),
.card__table .data-table td:nth-child(4) { width: 90px; text-align: right; }

/* --- Rasio Table Force Fit --- */
#dialogRasioDb .dialog__table-container .data-table { width: 100%; table-layout: fixed; }
#dialogRasioDb .data-table th:nth-child(1),
#dialogRasioDb .data-table td:nth-child(1) { width: 40px; }
#dialogRasioDb .data-table th:nth-child(2),
#dialogRasioDb .data-table td:nth-child(2) { width: 44px; text-align: center; white-space: nowrap; }
#dialogRasioDb .data-table th:nth-child(3),
#dialogRasioDb .data-table td:nth-child(3) { width: 110px; }
#dialogRasioDb .data-table th:nth-child(4),
#dialogRasioDb .data-table td:nth-child(4) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dialogRasioDb .data-table th:nth-child(5),
#dialogRasioDb .data-table td:nth-child(5) { width: 70px; text-align: center; }
#dialogRasioDb .data-table th:nth-child(6),
#dialogRasioDb .data-table td:nth-child(6) { width: 70px; text-align: center; }
#dialogRasioDb .data-table th:nth-child(7),
#dialogRasioDb .data-table td:nth-child(7) { width: 80px; }
#dialogRasioDb .data-table__action-btn { width: 32px; height: 32px; min-width: 32px; flex-shrink: 0; }

/* ============================================
   Cust Accurate Gen - Styles
   ============================================ */

/* --- Override empty-state for dual layout --- */
.empty-state {
    display: block !important;
    flex-direction: unset !important;
    align-items: unset !important;
    max-width: 900px !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    margin: 24px auto 0 !important;
    text-align: left !important;
}

/* --- Dual Upload Section --- */
.dual-upload-section {
    display: flex;
    align-items: stretch;
    gap: 24px;
    width: 100%;
}

.upload-card {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--md-shape-xl);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.upload-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.upload-card__icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--md-shape-md);
    font-size: 1.2rem;
}

.upload-card__icon--pos {
    background: var(--md-primary-container);
    color: var(--md-primary);
}

.upload-card__icon--cust {
    background: #e8f5e9;
    color: #2e7d32;
}

.upload-card__info {
    flex: 1;
    min-width: 0;
}

.upload-card__title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--ink);
    margin: 0 0 4px 0;
}

.upload-card__subtitle {
    font-size: 0.82rem;
    color: var(--muted);
    margin: 0;
}

.upload-card__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 16px;
}

.upload-card__empty-icon {
    font-size: 2.5rem;
    color: var(--muted);
    opacity: 0.5;
}

.upload-card__active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    gap: 12px;
}

.upload-card__active-icon {
    font-size: 2rem;
    color: #2e7d32;
}

.upload-card__active-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink);
    text-align: center;
}

/* --- Divider --- */
.upload-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-top: 80px;
}

.upload-divider__line {
    width: 1px;
    height: 60px;
    background: var(--line);
}

.upload-divider__text {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Filled Button Secondary --- */
.filled-button--secondary {
    background-color: #2e7d32;
}

.filled-button--secondary:hover {
    box-shadow: 0 8px 24px rgba(46, 125, 50, 0.22);
}

/* --- Filled Button Small --- */
.filled-button--small {
    height: 32px;
    padding: 0 16px;
    font-size: 0.78rem;
    border-radius: 12px;
}

.filled-button--small i {
    font-size: 0.85rem;
}

/* --- CAG Icon --- */
.cag-icon {
    background: #e8f5e9;
    color: #2e7d32;
}

/* --- CAG Row Highlight --- */
.cag-row-replaced {
    background-color: #f1f8e9;
}

.cag-row-replaced:hover {
    background-color: #dcedc8;
}

/* --- CAG Name Display --- */
.cag-old-name {
    color: var(--muted);
    text-decoration: line-through;
    font-size: 0.85rem;
}

.cag-new-name {
    color: #2e7d32;
    font-weight: 700;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .dual-upload-section {
        flex-direction: column;
    }

    .upload-divider {
        flex-direction: row;
        padding-top: 0;
    }

    .upload-divider__line {
        width: 60px;
        height: 1px;
    }
}