/* ==========================================================================
   MusuBee Trade System - Premium Design System (CSS)
   ========================================================================== */

/* 1. Variables & Base Setup */
:root {
    --bg-app: #0b0f19;
    --bg-sidebar: #111827;
    --bg-card: #1f2937;
    --bg-header: rgba(17, 24, 39, 0.7);
    --border-color: #374151;
    
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --color-primary: #3b82f6;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    
    --font-sans: 'Outfit', 'Noto Sans JP', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
}

/* 2. App Layout Structure */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.app-sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    font-size: 24px;
    color: var(--color-primary);
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.brand-text {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.brand-text span {
    color: var(--color-primary);
}

.sidebar-menu {
    padding: 24px 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    transition: var(--transition-smooth);
}

.menu-item i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.menu-item:hover, .menu-item.active {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--text-primary);
}

.menu-item.active {
    border-left: 4px solid var(--color-primary);
    background-color: rgba(59, 130, 246, 0.15);
}

.sidebar-user {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* Main Area Container */
.app-main {
    margin-left: 260px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-header {
    height: 70px;
    background-color: var(--bg-header);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
}

.system-time {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.main-content {
    padding: 40px;
    flex-grow: 1;
}

.app-footer {
    padding: 24px 40px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* 3. Dashboard Analytics Widgets */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Status Cards Container */
.status-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.status-card {
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: var(--transition-smooth);
}

.status-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.card-icon {
    font-size: 28px;
    opacity: 0.85;
}

.card-info h3 {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.8;
    margin-bottom: 4px;
}

.card-value {
    font-size: 28px;
    font-weight: 700;
}

.card-value .unit {
    font-size: 14px;
    font-weight: 400;
    opacity: 0.8;
}

/* Card Gradients */
.grad-cyan { background: linear-gradient(135deg, #0891b2, #0e7490); }
.grad-blue { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.grad-purple { background: linear-gradient(135deg, #7c3aed, #6d28d9); }
.grad-orange { background: linear-gradient(135deg, #ea580c, #c2410c); }
.grad-green { background: linear-gradient(135deg, #059669, #047857); }
.grad-teal { background: linear-gradient(135deg, #0d9488, #0f766e); }
.grad-info { background: linear-gradient(135deg, #0284c7, #0369a1); }
.grad-billing { background: linear-gradient(135deg, #4f46e5, #4338ca); }

.text-red-500 {
    color: #ef4444;
}

.font-bold {
    font-weight: 700;
}

/* Details Grid Structure */
.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

@media (max-width: 1024px) {
    .details-grid {
        grid-template-columns: 1fr;
    }
}

.details-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.card-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-header h2 i {
    color: var(--color-primary);
}

.view-all {
    color: var(--color-primary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.view-all:hover {
    opacity: 0.8;
}

.card-body {
    padding: 24px;
    flex-grow: 1;
}

/* 4. Table Design */
.table-premium {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table-premium th, .table-premium td {
    padding: 16px;
    text-align: left;
}

.table-premium th {
    background-color: rgba(55, 65, 81, 0.3);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.table-premium td {
    border-bottom: 1px solid var(--border-color);
}

.table-premium tr:last-child td {
    border-bottom: none;
}

.table-premium tr:hover td {
    background-color: rgba(55, 65, 81, 0.2);
}

.text-primary {
    color: var(--color-primary);
}

/* 5. Progress Bars & Lists */
.progress-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.progress-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.location-name {
    font-weight: 500;
}

.location-count {
    color: var(--text-secondary);
}

.progress-bar-bg {
    height: 8px;
    background-color: rgba(55, 65, 81, 0.5);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--color-primary);
    border-radius: 4px;
    box-shadow: 0 0 8px var(--color-primary);
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 6. Alert Lists */
.alert-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.alert-item {
    background-color: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-left: 4px solid var(--color-danger);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.invoice-no {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.buyer-name {
    font-size: 12px;
    color: var(--text-secondary);
}

.due-date {
    font-size: 11px;
    color: var(--color-danger);
}

.alert-amount {
    font-weight: 700;
    color: var(--color-danger);
    font-size: 16px;
}

.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Message Styles */
.empty-msg {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    padding: 40px 0;
}

.success-msg {
    color: var(--color-success);
}

/* ==========================================================================
   4. Added Premium UI Styles (Items & Forms)
   ========================================================================== */

/* Action Bar & Forms */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.filter-form {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input, .form-group select, .form-group textarea {
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    min-width: 150px;
    transition: var(--transition-smooth);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.form-group input[readonly] {
    opacity: 0.75;
    cursor: not-allowed;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-family: var(--font-sans);
    transition: var(--transition-smooth);
}

.btn-primary {
    background-color: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background-color: #2563eb;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: #4b5563;
}

.btn-success {
    background-color: var(--color-success);
    color: #fff;
}

.btn-success:hover {
    background-color: #059669;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background-color: rgba(59, 130, 246, 0.08);
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 20px;
    font-size: 15px;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.mt-6 {
    margin-top: 24px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background-color: var(--border-color);
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-smooth);
}

.btn-icon:hover {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--color-primary);
}

/* Badges */
.badge-cyan { background-color: rgba(6, 182, 212, 0.15); color: #06b6d4; border: 1px solid rgba(6, 182, 212, 0.2); }
.badge-blue { background-color: rgba(59, 130, 246, 0.15); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.2); }
.badge-purple { background-color: rgba(139, 92, 246, 0.15); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.2); }
.badge-orange { background-color: rgba(249, 115, 22, 0.15); color: #f97316; border: 1px solid rgba(249, 115, 22, 0.2); }
.badge-green { background-color: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-secondary { background-color: rgba(107, 114, 128, 0.15); color: #9ca3af; border: 1px solid rgba(107, 114, 128, 0.2); }
.badge-info { background-color: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.2); }
.badge-teal { background-color: rgba(20, 184, 166, 0.15); color: #2dd4bf; border: 1px solid rgba(20, 184, 166, 0.2); }
.badge-success { background-color: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.2); }

/* Table Links & Tags */
.ref-link {
    color: var(--color-primary);
    text-decoration: none;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ref-link:hover {
    text-decoration: underline;
}

.category-tag {
    background-color: rgba(55, 65, 81, 0.4);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.model-name {
    font-weight: 600;
}

.manufacturer-name {
    font-size: 11px;
    color: var(--text-muted);
}

.invoice-status {
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.invoice-status.invoiced {
    color: var(--color-success);
}

.invoice-status.uninvoiced {
    color: var(--text-muted);
}

/* Premium Form Container */
.form-premium {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-group-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group-block label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group-block input, .form-group-block select, .form-group-block textarea {
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    width: 100%;
    transition: var(--transition-smooth);
}

.form-group-block textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.form-group-block input:focus, .form-group-block select:focus, .form-group-block textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.memo-cell {
    white-space: pre-wrap;
    line-height: 1.6;
    color: var(--text-primary);
}

.input-readonly {
    background-color: rgba(55, 65, 81, 0.3) !important;
    border-style: dashed !important;
    color: var(--text-secondary) !important;
    cursor: not-allowed;
}

.form-help {
    font-size: 11px;
    color: var(--text-muted);
}

.required {
    color: var(--color-danger);
    font-size: 11px;
    margin-left: 4px;
}

.form-button-bar {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
    margin-top: 12px;
}

.alert-box {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Timeline Layout */
.timeline-premium {
    display: flex;
    justify-content: space-between;
    position: relative;
    padding: 20px 0;
}

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

.step-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--border-color);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border: 3px solid var(--bg-card);
    transition: var(--transition-smooth);
}

.step-label {
    margin-top: 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
}

.step-line {
    position: absolute;
    top: 22px;
    left: calc(50% + 22px);
    width: calc(100% - 44px);
    height: 3px;
    background-color: var(--border-color);
    z-index: -1;
}

/* Timeline States */
.timeline-step.completed .step-icon {
    background-color: var(--color-primary);
    color: #fff;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.timeline-step.completed .step-label {
    color: var(--text-primary);
}

.timeline-step.completed .step-line {
    background-color: var(--color-primary);
}

.timeline-step.active .step-icon {
    background-color: var(--color-warning);
    color: #fff;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
    animation: pulse 2s infinite;
}

.timeline-step.active .step-label {
    color: var(--color-warning);
    font-weight: 600;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Specs Table */
.table-specs {
    width: 100%;
    border-collapse: collapse;
}

.table-specs th, .table-specs td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.table-specs th {
    width: 180px;
    font-weight: 600;
    color: var(--text-secondary);
    background-color: rgba(55, 65, 81, 0.1);
}

.table-specs tr:last-child th, .table-specs tr:last-child td {
    border-bottom: none;
}

/* Invoice Box Card */
.invoice-box {
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid var(--border-color);
}

.invoiced-success {
    background-color: rgba(16, 185, 129, 0.03);
    border-left: 4px solid var(--color-success);
}

.uninvoiced-warning {
    background-color: rgba(245, 158, 11, 0.03);
    border-left: 4px solid var(--color-warning);
}

.invoice-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.invoice-box-header .lbl {
    font-weight: 600;
    font-size: 14px;
}

.invoice-box-header .val {
    font-size: 16px;
    color: var(--color-primary);
}

.invoice-box-body .row-info {
    display: flex;
    justify-content: space-between;
}

.invoice-box-body .help-text {
    margin-top: 16px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
}

.case-badge {
    background-color: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    color: #c084fc;
    font-weight: 600;
}

/* Form: 新商品登録 追加項目 */
.form-section-title {
    margin: 28px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-section-title i {
    margin-right: 8px;
    color: var(--color-primary);
}

.form-row-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.input-with-prefix {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-prefix .input-prefix {
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 1.2em;
}

.input-with-prefix input {
    flex: 1;
}

.timeline-preview {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    background: rgba(55, 65, 81, 0.25);
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
}

@media (max-width: 640px) {
    .form-row-two {
        grid-template-columns: 1fr;
    }
}

/* PI 作成フォーム・共通フォーム */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-grid-full {
    grid-column: 1 / -1;
}

.form-control {
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    width: 100%;
    transition: var(--transition-smooth);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.form-group textarea.form-control {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.form-divider {
    margin: 28px 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

.form-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-success);
    cursor: pointer;
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-unit .unit {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.input-with-unit .form-control {
    flex: 1;
}

.memo-preview {
    max-width: 180px;
    color: var(--text-secondary);
    font-size: 13px;
}

.pi-summary-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pi-summary-row {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 12px;
    align-items: start;
}

.pi-summary-row dt {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.pi-summary-row dd {
    margin: 0;
    font-size: 14px;
    color: var(--text-primary);
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .pi-summary-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}
