/* ============================================================
   dialogs.css — Toast, กล่องยืนยัน/กรอกข้อความ, แถบสถานะการเชื่อมต่อ
   (โหลดหลัง main.css / inventory.css / borrow.css)
   ============================================================ */

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(92vw, 440px);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28);
    pointer-events: auto;
    cursor: pointer;
    animation: toast-in 0.18s ease-out;
}

.toast i { margin-top: 2px; font-size: 16px; }
.toast-warn    { background: #b45309; }
.toast-error   { background: #b91c1c; }
.toast-success { background: #047857; }
.toast-info    { background: #1e293b; }

.toast.leaving { opacity: 0; transition: opacity 0.2s; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Dialog (อยู่เหนือ modal อื่นๆ) ---------- */
.app-dialog-overlay { z-index: 2000; }

.modal-card.app-dialog {
    max-width: 400px;
    max-height: 92vh;
    overflow-y: auto;
}

.app-dialog #appDialogMessage {
    font-size: 15px;
    color: var(--text-main);
    white-space: pre-line;
    line-height: 1.5;
}

.app-dialog i.icon-lock.is-danger { color: var(--danger-color); }

.app-dialog-field {
    text-align: left;
    margin-bottom: 16px;
}

.app-dialog-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* ตัวอักษร 16px ขึ้นไป กัน iOS ซูมหน้าเองตอนแตะช่องกรอก */
.app-dialog-field .form-control {
    font-size: 17px;
    padding: 12px 14px;
}

.app-dialog-error {
    min-height: 0;
    margin-top: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--danger-color);
}

/* ปุ่มใหญ่ขึ้น แตะง่ายตอนมือเปื้อน/ใส่ถุงมือ */
.app-dialog .modal-actions button {
    min-height: 48px;
    font-size: 15px;
    padding: 10px 12px;
}

.btn-modal-confirm.danger { background: var(--danger-strong); }

.app-dialog button:focus-visible,
.app-dialog input:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.45);
    outline-offset: 2px;
}

/* ---------- สถานะการเชื่อมต่อ ---------- */
.status-dot:not(.online):not(.offline):not(.error) {
    animation: status-pulse 1.2s ease-in-out infinite;
}

.status-dot.offline,
.status-dot.error {
    background-color: var(--danger-color);
    box-shadow: 0 0 8px var(--danger-color);
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

.connection-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    border: 1.5px solid;
}

.connection-banner[hidden] { display: none; }

.connection-banner.offline {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #78350f;
}

.connection-banner.error {
    background: #fef2f2;
    border-color: var(--danger-color);
    color: #7f1d1d;
}

.connection-banner .banner-text { flex: 1; min-width: 200px; }

.connection-banner .banner-retry {
    background: var(--text-main);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    min-height: 44px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
    .toast, .status-dot { animation: none !important; }
}

/* ---------- Modal รูปขยาย: สถานะกำลังโหลดรูปเต็ม ---------- */
#modalImageDisplay.is-loading {
    opacity: 0.6;
    min-width: 120px;
    min-height: 120px;
    background: #ffffff;
    object-fit: contain;
}

.modal-image-loading {
    margin-top: 10px;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
}

/* ---------- Modal ดูแลข้อมูลและพื้นที่ ---------- */
.modal-card.maint-card {
    max-width: 520px;
    text-align: left;
}

.maint-card > i.icon-lock,
.maint-card > h3,
.maint-card > p {
    text-align: center;
    display: block;
}

.maint-section {
    padding: 14px 0;
    border-top: 1px dashed var(--border-color);
}

.maint-section h4 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}

.maint-card .maint-desc {
    font-size: 13.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.5;
}

.btn-maint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 16px;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.btn-maint:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-maint.primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
}

.btn-maint.primary:hover:not(:disabled) {
    background: var(--primary-hover);
    color: #ffffff;
}

/* ปุ่มที่ลบข้อมูลถาวร (กู้คืนไม่ได้) — สีแยกจากปุ่มอื่นชัดเจน กันกดพลาด */
.btn-maint.danger {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: #ffffff;
}

.btn-maint.danger:hover:not(:disabled) {
    background: #dc2626;
    color: #ffffff;
}

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

.maint-meter {
    height: 14px;
    margin-top: 12px;
    background: #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.maint-meter-bar {
    height: 100%;
    border-radius: 8px;
    background: var(--success-strong);
}

.maint-meter.warn .maint-meter-bar   { background: var(--warning-strong); }
.maint-meter.danger .maint-meter-bar { background: var(--danger-strong); }

.maint-meter-text {
    margin-top: 6px;
    font-size: 14px;
    color: var(--text-main);
}

.maint-table {
    width: 100%;
    margin-top: 8px;
    border-collapse: collapse;
    font-size: 13.5px;
}

.maint-table td {
    padding: 5px 4px;
    border-bottom: 1px solid #f1f5f9;
}

.maint-table td:last-child {
    text-align: right;
    font-weight: 700;
    white-space: nowrap;
}

.maint-note {
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.maint-progress {
    min-height: 20px;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-hover);
}
