/* === WOP - Wholesale Order Portal === */
/* Dark brown coffee-shop theme for Nitta Coffee */

:root {
    --brown-900: #2c1810;
    --brown-800: #3e2723;
    --brown-700: #4e342e;
    --brown-600: #5d4037;
    --brown-500: #6d4c41;
    --brown-400: #8d6e63;
    --brown-300: #a1887f;
    --brown-200: #bcaaa4;
    --brown-100: #d7ccc8;
    --brown-50: #efebe9;
    --cream: #faf8f5;
    --cream-dark: #f0ebe4;
    --gold: #c49a6c;
    --gold-dark: #a67c52;
    --text-primary: #2c1810;
    --text-secondary: #5d4037;
    --text-muted: #8d6e63;
    --success: #2e7d32;
    --success-bg: #e8f5e9;
    --warning: #f57f17;
    --warning-bg: #fff8e1;
    --danger: #c62828;
    --danger-bg: #ffebee;
    --info: #1565c0;
    --info-bg: #e3f2fd;
    --border: #d7ccc8;
    --shadow: rgba(44, 24, 16, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif;
    background: var(--cream);
    color: var(--text-primary);
    line-height: 1.6;
}

/* === Utilities === */
.text-center { text-align: center; }
.text-danger { color: var(--danger) !important; }

/* === Forms === */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 14px; color: var(--text-secondary); }
.required { color: var(--danger); }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 15px; background: #fff; transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--brown-500); box-shadow: 0 0 0 3px rgba(109,76,65,0.15);
}
.form-input-sm { padding: 5px 8px; font-size: 13px; border: 1px solid var(--border); border-radius: 4px; }
.form-textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

/* === Buttons === */
.btn {
    display: inline-block; padding: 8px 18px; border: none; border-radius: 6px;
    font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
    transition: all 0.2s; text-align: center; line-height: 1.4;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary { background: var(--brown-600); color: #fff; }
.btn-primary:hover { background: var(--brown-700); }
.btn-secondary { background: var(--brown-100); color: var(--text-primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-full { width: 100%; }
.btn-large { padding: 14px 28px; font-size: 16px; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-group { display: flex; gap: 12px; flex-wrap: wrap; }

/* === Alerts === */
.alert {
    padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px;
}
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #ffcdd2; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #c8e6c9; }

/* === Status badges === */
.status-badge {
    display: inline-block; padding: 2px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 600;
}
.status-new { background: var(--info-bg); color: var(--info); }
.status-confirmed { background: var(--warning-bg); color: var(--warning); }
.status-delivered { background: var(--success-bg); color: var(--success); }
.status-cancelled { background: #f5f5f5; color: #999; }
.status-active { background: var(--success-bg); color: var(--success); }
.status-inactive { background: #f5f5f5; color: #999; }

/* === Login === */
.login-container {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--brown-800), var(--brown-600));
    padding: 20px;
}
.login-box {
    background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-header { text-align: center; margin-bottom: 30px; }
.login-header h1 { color: var(--brown-800); font-size: 28px; letter-spacing: 2px; }
.login-subtitle { color: var(--text-muted); margin-top: 4px; font-size: 14px; }

/* === Dealer Portal === */
.dealer-container { max-width: 800px; margin: 0 auto; padding: 0 16px 40px; }
.dealer-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 0; border-bottom: 2px solid var(--brown-200); margin-bottom: 20px;
}
.header-left h1 { font-size: 20px; color: var(--brown-800); }
.dealer-name { font-size: 14px; color: var(--text-muted); }
.header-nav { display: flex; gap: 16px; }
.nav-link { color: var(--brown-500); text-decoration: none; font-size: 14px; font-weight: 600; }
.nav-link:hover { color: var(--brown-800); }

/* Announcements */
.announcement {
    background: var(--info-bg); border: 1px solid #bbdefb; border-radius: 8px;
    padding: 12px 16px; margin-bottom: 12px;
}
.dealer-notice {
    background: var(--warning-bg); border: 1px solid #fff9c4; border-radius: 8px;
    padding: 12px 16px; margin-bottom: 12px;
}

/* Delivery info */
.delivery-info {
    display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.delivery-badge, .cutoff-badge {
    background: var(--brown-50); border: 1px solid var(--border);
    padding: 8px 16px; border-radius: 8px; font-size: 14px;
}
.cutoff-today { color: var(--danger); font-weight: 700; }
.cutoff-soon { color: var(--warning); font-weight: 700; }

/* Category sections */
.category-section {
    background: #fff; border-radius: 12px; padding: 20px;
    margin-bottom: 16px; box-shadow: 0 2px 8px var(--shadow);
}
.category-title {
    font-size: 18px; color: var(--brown-700); margin-bottom: 16px;
    padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.unit-badge { font-size: 13px; color: var(--text-muted); font-weight: 400; }

/* Product rows */
.product-row {
    display: flex; align-items: center; gap: 12px; padding: 10px 0;
    border-bottom: 1px solid #f0ebe4;
}
.product-row:last-child { border-bottom: none; }
.product-name { flex: 1; font-size: 15px; font-weight: 500; }
.qty-control { display: flex; align-items: center; gap: 4px; }
.qty-btn {
    width: 36px; height: 36px; border: 2px solid var(--brown-300); border-radius: 50%;
    background: #fff; font-size: 18px; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--brown-600); transition: all 0.15s;
}
.qty-btn:hover { background: var(--brown-100); }
.qty-btn:active { transform: scale(0.95); }
.qty-input {
    width: 56px; text-align: center; padding: 6px; border: 1px solid var(--border);
    border-radius: 6px; font-size: 16px; font-weight: 600;
}
.qty-input:focus { outline: none; border-color: var(--brown-500); }
.unit-label { font-size: 13px; color: var(--text-muted); min-width: 36px; }
.product-subtotal { font-size: 13px; color: var(--gold-dark); font-weight: 600; min-width: 70px; text-align: right; }

/* Category total */
.category-total {
    margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--brown-200);
    font-size: 16px; font-weight: 700; color: var(--brown-700);
}
.min-check { font-size: 14px; font-weight: 500; }
.min-ok { color: var(--success); }
.min-ng { color: var(--danger); }

/* Memo */
.memo-section { margin-top: 20px; padding: 16px; background: #fff; border-radius: 12px; box-shadow: 0 2px 8px var(--shadow); }
.memo-label { display: block; font-weight: bold; margin-bottom: 8px; color: var(--brown); }
.memo-input { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; font-family: inherit; resize: vertical; }
.memo-input:focus { outline: none; border-color: var(--brown); box-shadow: 0 0 0 2px rgba(92,61,46,0.1); }
.memo-display { margin-top: 16px; padding: 12px 16px; background: #f9f7f5; border-left: 3px solid var(--brown); border-radius: 4px; }
.memo-display p { margin: 4px 0 0; white-space: pre-wrap; }

/* Order actions */
.order-actions {
    display: flex; gap: 12px; justify-content: center; margin-top: 24px;
    padding: 20px; background: #fff; border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

/* Confirm page */
.confirm-section, .complete-section, .order-detail-section {
    background: #fff; border-radius: 12px; padding: 24px;
    box-shadow: 0 2px 8px var(--shadow);
}
.confirm-table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.confirm-table th, .confirm-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.confirm-table th { background: var(--brown-50); font-size: 13px; color: var(--text-muted); }
.category-header-row td { background: var(--cream-dark); font-weight: 600; font-size: 14px; }
.coffee-total-confirm {
    font-size: 16px; font-weight: 700; padding: 12px; background: var(--brown-50);
    border-radius: 8px; margin: 12px 0;
}
.confirm-actions { margin-top: 24px; text-align: center; }

/* Complete page */
.complete-icon { font-size: 64px; text-align: center; margin: 20px 0; }
.complete-section h2 { text-align: center; margin-bottom: 24px; }
.order-summary-card {
    background: var(--brown-50); border-radius: 8px; padding: 16px; margin-bottom: 20px;
}
.summary-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.summary-row:last-child { border-bottom: none; }
.summary-label { color: var(--text-muted); font-size: 14px; }
.summary-value { font-weight: 600; }
.complete-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; }

/* Order history */
.order-list { display: flex; flex-direction: column; gap: 8px; }
.order-card {
    display: block; background: #fff; border-radius: 8px; padding: 14px 16px;
    text-decoration: none; color: inherit; box-shadow: 0 1px 4px var(--shadow);
    transition: box-shadow 0.2s;
}
.order-card:hover { box-shadow: 0 4px 12px var(--shadow); }
.order-card-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.order-number { font-weight: 600; font-size: 14px; }
.order-card-body { display: flex; gap: 16px; font-size: 13px; color: var(--text-muted); }
.order-actions-detail { margin-top: 20px; text-align: center; }

/* Calendar */
.calendar-section { margin-top: 32px; }
.calendar-section h2 { margin-bottom: 16px; }
.calendar-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.calendar-month h3 { text-align: center; margin-bottom: 8px; font-size: 15px; }
.cal-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
.cal-table th { padding: 8px 4px; font-size: 12px; color: var(--text-muted); background: var(--brown-50); text-align: center; }
.cal-table td { padding: 8px 4px; text-align: center; font-size: 13px; border: 1px solid #f0ebe4; }
.cal-today { background: var(--brown-100) !important; font-weight: 700; outline: 2.5px solid var(--brown-600, #5d4037); outline-offset: -2px; border-radius: 4px; }
.cal-delivery { background: #e8f5e9 !important; font-weight: 600; }
.cal-cutoff { background: #fff3e0 !important; }
.cal-holiday { color: var(--danger); }
.cal-table-admin td { position: relative; min-height: 40px; vertical-align: top; padding: 4px; }
.cal-table-admin td small { font-size: 10px; display: block; }
.override-label { color: var(--info); }

.calendar-legend { display: flex; gap: 16px; margin-top: 12px; justify-content: center; font-size: 13px; }
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-color { width: 16px; height: 16px; border-radius: 3px; display: inline-block; }
.cal-delivery-bg { background: #e8f5e9; border: 1px solid #c8e6c9; }
.cal-cutoff-bg { background: #fff3e0; border: 1px solid #ffe0b2; }
.cal-holiday-bg { background: #ffebee; border: 1px solid #ffcdd2; }

.empty-message { color: var(--text-muted); text-align: center; padding: 40px; font-size: 15px; }

/* === Admin Layout === */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 240px; background: var(--brown-800); color: #fff;
    flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0;
    overflow-y: auto; z-index: 100;
}
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--brown-600); }
.sidebar-header h2 { font-size: 18px; letter-spacing: 1px; }
.admin-user { font-size: 12px; color: var(--brown-300); }
.sidebar-nav { list-style: none; padding: 8px 0; }
.sidebar-nav li a {
    display: block; padding: 10px 20px; color: var(--brown-200);
    text-decoration: none; font-size: 14px; transition: all 0.15s;
}
.sidebar-nav li a:hover { background: var(--brown-700); color: #fff; }
.sidebar-nav li a.active { background: var(--brown-600); color: #fff; font-weight: 600; }
.sidebar-divider { border-top: 1px solid var(--brown-600); margin: 8px 0; }

.admin-main { flex: 1; margin-left: 240px; padding: 24px 32px; min-width: 0; }

/* Admin page components */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-header h1 { font-size: 22px; color: var(--brown-800); }

.section { margin-bottom: 28px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section h2 { font-size: 17px; color: var(--brown-700); margin-bottom: 12px; }

/* Dashboard cards */
.dashboard-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.dash-card {
    background: #fff; border-radius: 12px; padding: 20px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: 0 2px 8px var(--shadow);
}
.dash-card-icon { font-size: 32px; }
.dash-card-label { font-size: 12px; color: var(--text-muted); }
.dash-card-value { font-size: 24px; font-weight: 700; color: var(--brown-800); }

/* Data table */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px var(--shadow); }
.data-table th { padding: 10px 14px; background: var(--brown-50); font-size: 13px; color: var(--text-muted); text-align: left; font-weight: 600; }
.data-table td { padding: 10px 14px; border-bottom: 1px solid #f0ebe4; font-size: 14px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table a { color: var(--brown-600); text-decoration: none; font-weight: 600; }
.data-table a:hover { text-decoration: underline; }
.row-inactive { opacity: 0.5; }

/* Detail card */
.detail-card {
    background: #fff; border-radius: 12px; padding: 24px;
    box-shadow: 0 2px 8px var(--shadow);
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.detail-item { padding: 8px 0; }
.detail-label { font-size: 12px; color: var(--text-muted); display: block; }
.detail-value { font-size: 15px; font-weight: 600; }
.detail-actions { display: flex; gap: 12px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }

/* Filter bar */
.filter-bar { margin-bottom: 16px; }
.filter-form { display: flex; gap: 12px; }
.filter-form .form-select { width: auto; min-width: 150px; }

/* Admin form */
.admin-form { background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 2px 8px var(--shadow); }
.form-section { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: none; }
.form-section h3 { font-size: 16px; color: var(--brown-700); margin-bottom: 12px; }
.form-actions { display: flex; gap: 12px; padding-top: 16px; }
.inline-form { background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 4px var(--shadow); }

/* Checkboxes */
.product-checkboxes { display: grid; grid-template-columns: 1fr; gap: 6px; }
.product-assign-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.product-assign-row .checkbox-label { flex: 0 0 auto; min-width: 250px; }
.display-name-input { flex: 1; min-width: 180px; max-width: 300px; padding: 4px 8px; font-size: 13px; border: 1px solid var(--brown-200); border-radius: 4px; }
.display-name-input:disabled { background: var(--cream); opacity: 0.5; }
.form-help { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 4px; font-size: 14px; cursor: pointer; }
.checkbox-label:hover { background: var(--brown-50); }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; }

/* Dealer select grid */
.dealer-select-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.dealer-select-card {
    background: #fff; border-radius: 8px; padding: 16px; text-decoration: none;
    color: inherit; box-shadow: 0 1px 4px var(--shadow); transition: all 0.2s;
    text-align: center;
}
.dealer-select-card:hover { box-shadow: 0 4px 12px var(--shadow); transform: translateY(-2px); }
.dealer-select-code { font-size: 12px; color: var(--text-muted); }
.dealer-select-name { font-size: 16px; font-weight: 600; margin-top: 4px; }

/* Announcement card (admin) */
.announcement-card {
    background: #fff; border-radius: 8px; padding: 16px; margin-bottom: 12px;
    box-shadow: 0 1px 4px var(--shadow);
}

/* Calendar nav */
.calendar-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* Preview section */
.preview-section { margin-top: 20px; }
.preview-section h4 { margin-top: 16px; margin-bottom: 8px; color: var(--brown-700); }
.import-confirm-form { margin-top: 16px; padding: 16px; background: var(--brown-50); border-radius: 8px; }
.help-text { font-size: 13px; color: var(--text-muted); margin: 8px 0; }

/* === Mobile Responsive === */
@media (max-width: 768px) {
    .admin-sidebar {
        position: fixed; left: -240px; transition: left 0.3s;
    }
    .admin-sidebar.open { left: 0; }
    .admin-main { margin-left: 0; padding: 16px; }

    .dealer-header { flex-direction: column; gap: 8px; text-align: center; }
    .header-nav { justify-content: center; }

    .calendar-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .dashboard-cards { grid-template-columns: 1fr 1fr; }
    .detail-grid { grid-template-columns: 1fr; }

    .product-row { flex-wrap: wrap; }
    .product-name { flex-basis: 100%; }
    .product-subtotal { flex-basis: 100%; text-align: left; padding-left: 4px; }

    .order-actions { flex-direction: column; }
    .btn-group { flex-direction: column; }

    .data-table { font-size: 13px; }
    .data-table th, .data-table td { padding: 8px; }

    .filter-form { flex-direction: column; }
    .filter-form .form-select { width: 100%; }
}

@media (max-width: 480px) {
    .dashboard-cards { grid-template-columns: 1fr; }
    .dealer-select-grid { grid-template-columns: 1fr; }
    .login-box { padding: 24px; }
}

/* Print styles */
@media print {
    .admin-sidebar, .header-nav, .btn, .filter-bar, .form-actions { display: none !important; }
    .admin-main { margin-left: 0; padding: 0; }
    .data-table { box-shadow: none; }
}
