/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
    background: #f0f2f5; color: #333; line-height: 1.6;
}
a { color: #0077B6; text-decoration: none; }
a:hover { color: #023e8a; }
img { max-width: 100%; }

/* ===== Colors ===== */
:root {
    --primary: #00B4D8;
    --primary-dark: #0077B6;
    --primary-light: #90E0EF;
    --secondary: #023e8a;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --gray: #6c757d;
    --light: #f8f9fa;
    --dark: #343a40;
    --border: #dee2e6;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 8px;
}

/* ===== Typography ===== */
h1, h2, h3, h4 { line-height: 1.3; color: var(--dark); }
.required { color: var(--danger); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 20px; border: none; border-radius: var(--radius);
    font-size: 0.95rem; font-weight: 500; cursor: pointer;
    transition: all 0.2s; text-decoration: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-info { background: var(--primary-light); color: var(--dark); }
.btn-secondary { background: var(--gray); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 0.9rem; color: #555; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
    border-radius: var(--radius); font-size: 0.95rem; transition: border 0.2s;
    font-family: inherit; background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,180,216,0.15);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ===== Alert ===== */
.alert {
    padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
    font-size: 0.9rem; border-left: 4px solid transparent;
}
.alert-error { background: #fde8e8; color: #c0392b; border-left-color: var(--danger); }
.alert-success { background: #e8f8f0; color: #27ae60; border-left-color: var(--success); }
.alert-info { background: #e8f4fd; color: #2980b9; border-left-color: var(--primary); }

/* ===== Tables ===== */
.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.main-content { overflow-x: hidden; max-width: 100vw; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
thead { background: var(--primary-dark); color: #fff; }
th, td { padding: 12px 16px; text-align: left; font-size: 0.9rem; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:hover { background: #f1f8ff; }
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 0.8rem; font-weight: 500;
}
.badge-pending { background: #ffeaa7; color: #856404; }
.badge-evaluated { background: #81ecec; color: #006266; }
.badge-quoted { background: #74b9ff; color: #0551a6; }
.badge-assigned { background: #a29bfe; color: #3c22a6; }
.badge-completed { background: #55efc4; color: #006644; }
.badge-done { background: #00b894; color: #fff; }
.badge-cancelled { background: #fab1a0; color: #922b21; }
.badge-warning { background: #ffeaa7; color: #856404; }
.badge-info { background: #81ecec; color: #006266; }

/* ===== Login Page ===== */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: linear-gradient(135deg, #00B4D8 0%, #0077B6 100%);
}
.login-container { width: 100%; max-width: 420px; padding: 20px; }
.login-card {
    background: #fff; border-radius: 16px; padding: 40px 36px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.login-header { text-align: center; margin-bottom: 24px; }
.login-header .logo-icon { font-size: 3rem; margin-bottom: 8px; }
.login-header h1 { font-size: 1.5rem; color: var(--primary-dark); margin-bottom: 4px; }
.login-header p { color: var(--gray); font-size: 0.9rem; }
.login-footer { display: flex; justify-content: space-between; margin-top: 20px; font-size: 0.85rem; }

/* ===== Layout ===== */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; background: var(--dark); color: #fff;
    display: flex; flex-direction: column; position: fixed;
    top: 0; left: 0; height: 100vh; z-index: 100; transition: all 0.3s;
}
.sidebar-header {
    padding: 20px; text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header h2 { font-size: 1.1rem; color: #fff; }
.sidebar-header p { font-size: 0.8rem; color: rgba(255,255,255,0.6); }
.sidebar-nav { flex: 1; padding: 8px 0; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 16px; color: rgba(255,255,255,0.7);
    text-decoration: none; transition: all 0.2s; font-size: 0.8rem;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255,255,255,0.1); color: #fff;
}
.sidebar-nav a .icon { font-size: 1rem; width: 20px; text-align: center; }
.sidebar-nav a { position: relative; }
.nav-group-title {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 16px; color: rgba(255,255,255,0.7);
    cursor: pointer; font-size: 0.8rem; user-select: none;
    transition: all 0.2s;
}
.nav-group-title .nav-badge {
    position: relative; right: auto; top: auto;
    transform: none;
}
.nav-group-title:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-arrow { margin-left: auto; font-size: 0.7rem; transition: transform 0.2s; }
.nav-group.open .nav-arrow { transform: rotate(90deg); }
.nav-group-items { overflow: hidden; max-height: 0; transition: max-height 0.25s ease; }
.nav-group.open .nav-group-items { max-height: 600px; }
.nav-group.open .nav-group-items { max-height: none; overflow-y: auto; }
.nav-group-items a { padding-left: 40px !important; font-size: 0.8rem !important; }
.nav-group-items .nav-badge, .sidebar-nav > a > .nav-badge { position: relative; right: auto; top: auto; transform: none; }
.nav-group-items .nav-badge { background: #e67e22; }
.nav-badge {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: var(--danger); color: #fff; font-size: 0.65rem; font-weight: 700;
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center; line-height: 1;
}
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-footer .user-info { font-size: 0.85rem; margin-bottom: 8px; }
.sidebar-footer .user-info strong { display: block; color: #fff; }
.sidebar-footer .user-info span { color: rgba(255,255,255,0.6); font-size: 0.8rem; }

.main-content {
    flex: 1; margin-left: 250px; padding: 24px 32px;
}
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 1.5rem; }

/* ===== Cards ===== */
.card {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 24px; margin-bottom: 20px;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.card-header h2, .card-header h3 { font-size: 1.1rem; }
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; text-align: center;
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary-dark); }
.stat-card .stat-label { font-size: 0.85rem; color: var(--gray); margin-top: 4px; }
.stat-card .stat-icon { font-size: 2rem; margin-bottom: 8px; }

/* ===== Service Cards (Consumer) ===== */
.service-selection { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 16px; }
.service-card {
    background: #fff; border: 2px solid var(--border); border-radius: var(--radius);
    padding: 14px 12px; text-align: center; cursor: pointer;
    transition: all 0.2s;
}
.service-card:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow); }
.service-card.selected { border-color: var(--primary); background: #e8f8ff; }
.service-card .service-icon { font-size: 1.2rem; display:inline; }
.service-card h3 { font-size: 0.85rem; display:inline; margin-left:4px; }
.service-card p { font-size: 0.75rem; color: var(--gray); margin-top:4px; }

/* ===== Hero (Customer Front) ===== */
.hero {
    background: linear-gradient(135deg, #00B4D8 0%, #0077B6 100%);
    color: #fff; padding: 60px 32px; text-align: center;
}
.hero h1 { font-size: 2rem; color: #fff; margin-bottom: 8px; }
.hero p { font-size: 1rem; opacity: 0.9; margin-bottom: 0; }
.hero-steps {
    display: flex; justify-content: center; gap: 40px; margin-top: 32px;
    flex-wrap: wrap;
}
.hero-step { text-align: center; }
.hero-step .step-num {
    width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 8px; font-weight: 700; font-size: 1.1rem;
}
.hero-step .step-label { font-size: 0.85rem; opacity: 0.9; }

/* ===== Consumer Page ===== */
.customer-page { background: var(--light); }
.customer-page .container { max-width: 700px; margin: 0 auto; padding: 32px 20px; }

/* ===== Status Timeline ===== */
.timeline { position: relative; padding-left: 30px; }
.timeline::before {
    content: ''; position: absolute; left: 10px; top: 0; bottom: 0;
    width: 2px; background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before {
    content: ''; position: absolute; left: -24px; top: 4px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--border);
}
.timeline-item.active::before { background: var(--primary); box-shadow: 0 0 0 3px rgba(0,180,216,0.3); }
.timeline-item.completed::before { background: var(--success); }
.timeline-item .time-label { font-size: 0.8rem; color: var(--gray); }
.timeline-item .time-text { font-size: 0.9rem; }

/* ===== Actions ===== */
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Hamburger ===== */
.hamburger {
    display: none; position: fixed; top: 12px; left: 12px; z-index: 200;
    width: 36px; height: 36px; background: var(--primary-dark); border: none;
    border-radius: 8px; cursor: pointer; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px; padding: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.hamburger span {
    display: block; width: 20px; height: 2.5px; background: #fff;
    border-radius: 2px; transition: all 0.2s;
}
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(4.5px, 4.5px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(4.5px, -4.5px); }

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

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .hamburger { display: flex; }
    .sidebar {
        transform: translateX(-100%); width: 260px;
        transition: transform 0.25s ease;
        box-shadow: 2px 0 20px rgba(0,0,0,0.2);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .main-content { margin-left: 0; padding: 16px; padding-top: 60px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
    .stat-card { padding: 12px 8px; }
    .stat-card .stat-value { font-size: 1.2rem; }
    .stat-card .stat-label { font-size: 0.75rem; }
    .stat-card .stat-icon { font-size: 1.3rem; margin-bottom: 4px; }
    .hero { padding: 40px 20px; }
    .hero h1 { font-size: 1.5rem; }
    .hero-steps { gap: 20px; }
}
@media print {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .btn, .action-bar { display: none; }
}

/* ===== Extra ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.w-full { width: 100%; }

/* ===== Tab Navigation ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.tab { padding: 10px 20px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; color: var(--gray); font-weight: 500; font-size: 0.9rem; transition: all 0.2s; }
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary-dark); border-bottom-color: var(--primary-dark); }
.svc-row select { font-size: 0.85rem; }
.svc-row input[type="number"] { font-size: 0.85rem; }
.svc-row select option { font-size: 0.85rem; }
