/* ============================================================
   見積書システム - スタイルシート
   ============================================================ */

/* --- Base / Layout ----------------------------------------- */
body {
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    font-size: 14px;
    background-color: #f5f5f5;
    color: #333;
}

.container-fluid {
    max-width: 1400px;
}

a {
    text-decoration: none;
}

/* --- Navbar ------------------------------------------------- */
.navbar-brand {
    font-size: 1.1rem;
    letter-spacing: 0.03em;
}

.navbar .nav-link {
    font-size: 0.95rem;
}

.navbar .nav-link.active {
    font-weight: 600;
    border-bottom: 2px solid #fff;
}

/* --- Page Headers ------------------------------------------ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #dee2e6;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    color: #212529;
}

/* --- Cards -------------------------------------------------- */
.card {
    border: 1px solid #dee2e6;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.card-header {
    font-weight: 600;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

/* --- Status Badges ------------------------------------------ */
.badge {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35em 0.7em;
    letter-spacing: 0.03em;
}

/* --- Estimate List Table ------------------------------------ */
.table-estimates thead th {
    background-color: #343a40;
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    vertical-align: middle;
}

.table-estimates tbody tr:hover {
    background-color: #f0f4ff;
}

.table-estimates td {
    vertical-align: middle;
}

.table-estimates .amount-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}

/* --- Estimate Form ------------------------------------------ */
.form-section {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.form-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #495057;
    margin-bottom: 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #dee2e6;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Items Spreadsheet Table ------------------------------- */
.estimate-table-wrapper {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.estimate-table {
    margin-bottom: 0;
    table-layout: fixed;
    min-width: 820px;
}

.estimate-table thead th {
    background-color: #495057;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: middle;
    padding: 6px 8px;
    letter-spacing: 0.03em;
}

.estimate-table tbody td {
    padding: 2px 4px;
    vertical-align: middle;
    border-bottom: 1px solid #e9ecef;
}

.estimate-table tbody tr:hover {
    background-color: #f8f9fa;
}

.estimate-table input[type="text"],
.estimate-table input[type="number"] {
    border: none;
    background: transparent;
    width: 100%;
    padding: 4px 6px;
    font-size: 0.9rem;
    color: #333;
    height: 32px;
    border-radius: 3px;
    transition: outline 0.1s, background 0.1s;
}

.estimate-table input[type="text"]:focus,
.estimate-table input[type="number"]:focus {
    outline: 2px solid #0d6efd;
    background: #fff;
    border-radius: 3px;
}

.estimate-table select {
    border: 1px solid transparent;
    background: transparent;
    width: 100%;
    padding: 4px 2px;
    font-size: 0.9rem;
    color: #333;
    height: 32px;
    border-radius: 3px;
    cursor: pointer;
    transition: border-color 0.1s, background 0.1s;
}

.estimate-table select:focus {
    outline: 2px solid #0d6efd;
    background: #fff;
    border-color: #0d6efd;
}

.estimate-table input[type="number"] {
    text-align: right;
}

.estimate-table .col-no      { width: 42px; text-align: center; }
.estimate-table .col-name    { width: 22%; }
.estimate-table .col-desc    { width: 28%; }
.estimate-table .col-qty     { width: 80px; }
.estimate-table .col-unit    { width: 75px; }
.estimate-table .col-price   { width: 110px; }
.estimate-table .col-amount  { width: 110px; }
.estimate-table .col-del     { width: 50px; text-align: center; }

.row-num {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 600;
}

.amount-col {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 0.9rem;
    padding-right: 8px !important;
    white-space: nowrap;
}

/* --- Totals Summary ---------------------------------------- */
.total-section {
    border-top: 2px solid #343a40;
    margin-top: 0;
}

.total-section table {
    width: 100%;
}

.total-section td {
    padding: 5px 8px;
    font-size: 0.95rem;
}

.total-section .label-col {
    text-align: right;
    color: #6c757d;
    width: 60%;
}

.total-section .value-col {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
    padding-right: 4px;
}

.total-section .grand-total td {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0d6efd;
    border-top: 1px solid #dee2e6;
    padding-top: 8px;
}

/* --- View Page ---------------------------------------------- */
.estimate-meta dt {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.estimate-meta dd {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: #212529;
}

.view-items-table thead th {
    background-color: #495057;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: middle;
    padding: 7px 10px;
}

.view-items-table tbody td {
    vertical-align: middle;
    padding: 7px 10px;
    font-size: 0.92rem;
    border-bottom: 1px solid #e9ecef;
}

.view-items-table .amount-col {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}

.view-items-table .qty-col,
.view-items-table .unit-col,
.view-items-table .price-col {
    text-align: right;
    white-space: nowrap;
}

/* --- Flash Messages ---------------------------------------- */
.flash-message {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 9999;
    min-width: 280px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

/* --- Status Filter Tabs ------------------------------------ */
.status-tabs .nav-link {
    font-size: 0.88rem;
    padding: 0.35rem 0.9rem;
    color: #495057;
}

.status-tabs .nav-link.active {
    font-weight: 700;
}

.status-tabs .badge {
    font-size: 0.7rem;
}

/* --- Customer Table ---------------------------------------- */
.table-customers thead th {
    background-color: #343a40;
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    vertical-align: middle;
}

.table-customers tbody tr:hover {
    background-color: #f0f4ff;
}

.table-customers td {
    vertical-align: middle;
}

/* --- Empty State ------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    opacity: 0.4;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 1.25rem;
}

/* --- Buttons ----------------------------------------------- */
.btn-action-group .btn {
    padding: 0.25rem 0.55rem;
    font-size: 0.8rem;
}

/* --- Add Row Button ---------------------------------------- */
#btn-add-row {
    font-size: 0.85rem;
    border-style: dashed;
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    body {
        background: #fff !important;
        font-size: 12pt;
    }

    nav.navbar,
    .page-header .btn,
    .action-buttons,
    #btn-add-row,
    .btn-delete-row,
    footer {
        display: none !important;
    }

    .container-fluid {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .card {
        border: none !important;
        box-shadow: none !important;
    }

    .card-header {
        background: none !important;
        border-bottom: 1px solid #000 !important;
    }

    .form-section {
        border: none !important;
        padding: 0 !important;
        margin-bottom: 0.5rem !important;
    }

    .estimate-table thead th {
        background-color: #333 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .view-items-table thead th {
        background-color: #333 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    a {
        color: inherit !important;
        text-decoration: none !important;
    }

    .badge {
        border: 1px solid #333;
    }

    .page-break {
        page-break-before: always;
    }
}

/* ============================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================ */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .table-estimates td,
    .table-estimates th {
        font-size: 0.8rem;
        padding: 0.4rem 0.5rem;
    }

    .total-section .label-col {
        width: 50%;
    }
}
