/* Kam Tin Workshop — Customer Portal
   Phase 1 — Mobile-first Responsive UI
   
   Colors:
     Orange:  #E87A2F / #D4691F
     Dark:    #2d3436
     Light:   #f5f6fa
     White:   #ffffff
*/

/* ─── Reset ─────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', Roboto, sans-serif;
    background: #f5f6fa;
    color: #2d3436;
    line-height: 1.6;
    min-height: 100vh;
    padding-top: 52px;  /* header height */
    padding-bottom: 72px; /* bottom nav height */
}

a { color: #0984e3; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Orange Header ─────────────────────────────── */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #E87A2F;
    color: white;
    height: 52px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
}

.hamburger {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    -webkit-tap-highlight-color: transparent;
}

.hamburger:active {
    background: rgba(255,255,255,0.15);
}

.header-title {
    font-size: 1.1em;
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

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

.btn-back {
    color: white;
    font-size: 0.85em;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
}
.btn-back:hover { background: rgba(255,255,255,0.15); text-decoration: none; }

.lang-switch {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 0.8em;
    white-space: nowrap;
}

.lang-item {
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.lang-item.active { opacity: 1; font-weight: 700; }
.lang-item:active { background: rgba(255,255,255,0.15); }

.lang-sep {
    opacity: 0.4;
    font-size: 0.9em;
}

/* ─── Slide Menu ────────────────────────────────── */
.slide-menu {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    z-index: 1100;
    background: white;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
    transition: left 0.3s ease;
    overflow-y: auto;
}

.slide-menu.open { left: 0; }

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    background: rgba(0,0,0,0.4);
    display: none;
}
.menu-overlay.show { display: block; }

.slide-menu-header {
    background: #E87A2F;
    padding: 20px 16px;
    color: white;
}

.slide-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slide-avatar {
    font-size: 2em;
}

.slide-name {
    font-size: 0.95em;
    font-weight: 600;
}

.slide-menu-items {
    list-style: none;
    padding: 8px 0;
}

.slide-menu-items li a {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: #2d3436;
    font-size: 0.95em;
    gap: 10px;
    transition: background 0.15s;
}

.slide-menu-items li a:active {
    background: #f0f0f0;
    text-decoration: none;
}

.slide-menu-items li a.disabled {
    color: #b2bec3;
    pointer-events: none;
}

.slide-menu-items li a.logout-link {
    color: #e17055;
}

.slide-divider {
    height: 1px;
    background: #dfe6e9;
    margin: 8px 16px;
}

/* ─── Main Content ──────────────────────────────── */
.app-main {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px 12px 20px;
    min-height: calc(100vh - 52px - 72px);
}

/* ─── Bottom Nav ────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    display: flex;
    border-top: 1px solid #dfe6e9;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    height: 62px;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #636e72;
    font-size: 0.7em;
    padding: 6px 4px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:active {
    background: #f8f9fa;
    text-decoration: none;
}

.bottom-nav-item.active {
    color: #E87A2F;
}

.nav-icon {
    font-size: 1.4em;
    line-height: 1;
}

.nav-label {
    font-weight: 500;
}

/* ─── Login Page ────────────────────────────────── */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 52px - 72px);
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 36px 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.08);
}

.login-card h1 {
    font-size: 1.3em;
    color: #E87A2F;
    margin-bottom: 4px;
    text-align: center;
}

.login-card h2 {
    font-size: 0.9em;
    color: #636e72;
    font-weight: 400;
    margin-bottom: 20px;
    text-align: center;
}

.login-footer {
    text-align: center;
    margin-top: 18px;
}

.forgot-link {
    font-size: 0.85em;
    color: #636e72;
}
.forgot-link:hover {
    color: #E87A2F;
    text-decoration: underline;
}

/* ─── Forms ─────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    color: #636e72;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #dfe6e9;
    border-radius: 10px;
    font-size: 1em;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.form-group input:focus {
    outline: none;
    border-color: #E87A2F;
    box-shadow: 0 0 0 3px rgba(232,122,47,0.12);
}

/* ─── Buttons ───────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 0.9em;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: #E87A2F;
    color: white;
}
.btn-primary:hover { background: #D4691F; }
.btn-primary:active { background: #C05E14; }

.btn-full { width: 100%; padding: 14px; font-size: 1em; }
.btn-sm { padding: 8px 14px; font-size: 0.85em; }

/* ─── Alerts ────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.9em;
}

.alert-error {
    background: #ffeaa7;
    color: #b71540;
    border: 1px solid #fab1a0;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* ─── Dashboard ────────────────────────────────── */
.dashboard {
    padding-bottom: 8px;
}

.dashboard h1 {
    font-size: 1.3em;
    margin-bottom: 4px;
}

.subtitle {
    color: #636e72;
    font-size: 0.9em;
    margin-bottom: 20px;
}

.stats {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    min-width: 100px;
}

.stat-number {
    font-size: 1.6em;
    font-weight: 700;
    color: #E87A2F;
}

.stat-label {
    font-size: 0.8em;
    color: #636e72;
}

/* ─── Order Table ──────────────────────────────── */
.order-table-wrapper {
    overflow-x: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
    -webkit-overflow-scrolling: touch;
}

.order-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 480px;
}

.order-table th {
    background: #f8f9fa;
    text-align: left;
    padding: 12px 14px;
    font-size: 0.8em;
    font-weight: 600;
    color: #636e72;
    border-bottom: 2px solid #dfe6e9;
    white-space: nowrap;
}

.order-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85em;
}

.order-table tr:last-child td { border-bottom: none; }
.order-table tr:active { background: #f8f9fa; }

.order-table td.order-table td.quotation-no {
    font-weight: 600;
    color: #0984e3;
}

.quotation-link {
    color: #0984e3;
    font-weight: 600;
    text-decoration: none;
}
.quotation-link:hover {
    color: #0652DD;
    text-decoration: underline;
}

.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 12px 42px 12px 16px;
    border: 1px solid #dfe6e9;
    border-radius: 12px;
    font-size: 0.9em;
    background: white;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.search-input:focus {
    outline: none;
    border-color: #E87A2F;
    box-shadow: 0 0 0 3px rgba(232,122,47,0.12);
}

.search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1em;
    pointer-events: none;
}

.lang-form {
    display: inline;
}

/* Order row clickable on mobile */
.order-row {
    cursor: pointer;
}
.order-row:active {
    background: #f0f0f0;
}

.order-table td.amount {
    font-weight: 600;
    color: #2d3436;
    text-align: left;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ─── Status Badge ─────────────────────────────── */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 1em;
    font-weight: 600;
    white-space: nowrap;
}

.status-準備中 { background: #ffeaa7; color: #856404; }
.status-可以設計 { background: #81ecec; color: #006266; }
.status-設計中 { background: #74b9ff; color: #055aa3; }
.status-印刷中 { background: #a29bfe; color: #382e6b; }
.status-印刷完成-自取 { background: #55efc4; color: #006644; }
.status-已送貨 { background: #00b894; color: white; }
.status-已完成 { background: #00cec9; color: white; }
.status-訂單已完成 { background: #00cec9; color: white; }
.status-訂單已取消 { background: #dfe6e9; color: #636e72; }
.status-印刷完成-已出貨 { background: #00b894; color: white; }

/* ─── Empty State ──────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #636e72;
    background: white;
    border-radius: 12px;
}

.search-empty {
    text-align: center;
    padding: 40px 20px;
    color: #636e72;
    background: white;
    border-radius: 12px;
    margin-top: 12px;
}

/* ─── Order Detail ─────────────────────────────── */
.breadcrumb {
    font-size: 0.8em;
    color: #636e72;
    margin-bottom: 12px;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 8px;
}

.detail-header h1 {
    font-size: 1.2em;
    color: #E87A2F;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

@media (min-width: 600px) {
    .info-grid { grid-template-columns: 1fr 1fr; }
}

.info-card {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.info-card h3 {
    font-size: 0.85em;
    color: #636e72;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.info-card dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 10px;
    font-size: 0.85em;
}

.info-card dt { color: #636e72; font-weight: 500; }
.info-card dd { font-weight: 500; }

.info-card .amount { color: #E87A2F; font-weight: 700; font-size: 1.1em; }
.info-card .amount-paid { color: #00b894; font-weight: 600; }
.info-card .amount-balance { color: #e17055; font-weight: 600; }

/* ─── Description ──────────────────────────────── */
.description-box {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.description-box h4 {
    font-size: 0.85em;
    color: #636e72;
    margin-bottom: 6px;
}

.description-box pre {
    font-family: inherit;
    font-size: 0.85em;
    line-height: 1.5;
    white-space: pre-wrap;
    color: #2d3436;
}

/* ─── Timeline ─────────────────────────────────── */
.status-timeline-wrapper {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
    margin-bottom: 20px;
}

.status-timeline-wrapper h3 {
    font-size: 0.85em;
    color: #636e72;
    margin-bottom: 14px;
}

.timeline {
    display: flex;
    justify-content: space-between;
    gap: 4px;
}

.timeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
}

.timeline-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 9px;
    left: 55%;
    width: 90%;
    height: 2px;
    background: #dfe6e9;
    z-index: 0;
}

.timeline-step.active:not(:last-child)::after {
    background: #E87A2F;
}

.step-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #dfe6e9;
    position: relative;
    z-index: 1;
    margin-bottom: 6px;
}

.timeline-step.active .step-dot {
    background: #E87A2F;
}

.step-label {
    font-size: 0.7em;
    font-weight: 500;
    color: #636e72;
    text-align: center;
}

.timeline-step.active .step-label {
    color: #E87A2F;
    font-weight: 600;
}

.step-status {
    font-size: 0.8em;
    color: #b2bec3;
    margin-top: 2px;
}

.timeline-step.active .step-status {
    color: #E87A2F;
    font-weight: 600;
}

.current-status {
    text-align: center;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
    font-size: 0.85em;
    color: #636e72;
}

.current-status strong {
    color: #E87A2F;
}

/* ─── Footer ───────────────────────────────────── */
.app-footer {
    text-align: center;
    padding: 12px 0 16px;
    color: #b2bec3;
}

.footer-text {
    font-size: 0.75em;
}

/* ─── Mobile Tweaks ────────────────────────────── */
@media (max-width: 400px) {
    .header-title { font-size: 0.95em; }
    .order-table td { font-size: 0.8em; padding: 10px 10px; }
    .order-table th { font-size: 0.75em; padding: 10px; }
    .stat-card { min-width: 80px; padding: 14px 16px; }
    .login-card { padding: 28px 20px; }
}

/* ─── Touch-friendly tap targets ───────────────── */
button, .btn, .bottom-nav-item, .hamburger, .lang-item {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
