/* style.css for resume-maker */

.resume-container {
    width: 95%;
    max-width: 1400px;
    margin: 20px auto;
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    color: #333;
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    box-sizing: border-box;
}

/* 共通パネルスタイル */
.panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    padding: 30px;
    box-sizing: border-box;
}

/* 左側：入力＆設定エリア */
.config-panel {
    flex: 1 1 400px;
    min-width: 0;
    /* Prevent panel from expanding the flex row */
    max-width: 100%;
    /* Hard upper limit */
    /* NOTE: Do NOT use overflow:hidden here - it clips form content like dropdowns */
}

.config-panel h3 {
    margin-top: 0;
    font-size: 1.25rem;
    color: #444;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 右側：プレビューエリア */
.preview-panel {
    flex: 1 1 400px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background: #fdfdfd;
    min-width: 0;
    /* Critical: allow flex child to shrink */
    max-width: 100%;
    /* Prevent expansion beyond available space */
    /* overflow:hidden here is OK because the preview uses transform scaling */
    overflow: hidden;
}

.preview-panel h3 {
    width: 100%;
    margin-top: 0;
    font-size: 1.25rem;
    color: #444;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
    margin-bottom: 20px;
    text-align: left;
}

.btn-download {
    background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 114, 255, 0.3);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 114, 255, 0.4);
}

.btn-download:disabled {
    background: #ccc;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Responsive Container */
@media (max-width: 1100px) {
    .resume-container {
        flex-direction: column;
        align-items: stretch;
    }
}

/* =========================================================
   1. Input Form Styles
========================================================= */
.resume-form {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.form-section {
    background: #fdfdfd;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #eee;
}

.form-section h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #4facfe;
    font-size: 1.1rem;
    border-bottom: 1px dashed #ccc;
    padding-bottom: 5px;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

/* Date input row: keep date parts on one line, fit full width */
.date-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    width: 100%;
    box-sizing: border-box;
}

.date-row input[type="number"] {
    flex: 1;
    min-width: 0;
    padding: 10px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    box-sizing: border-box;
    text-align: center;
}

.date-row .date-label {
    white-space: nowrap;
    font-size: 0.9rem;
    color: #333;
    flex-shrink: 0;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.85rem;
    color: #555;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    /* Fill parent but never exceed it */
    max-width: 100%;
    /* Hard stop */
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
    /* Ensure padding doesn't add to total width */
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #4facfe;
    outline: none;
}

.btn-add-row {
    background: #fff;
    border: 1px solid #4facfe;
    color: #4facfe;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-add-row:hover {
    background: #4facfe;
    color: #fff;
}

/* History Row specific tight layout */
.history-row-item {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
    flex-wrap: nowrap;
    width: 100%;
    overflow: hidden;
    /* Prevent internal inputs from expanding the row */
    box-sizing: border-box;
}

.history-row-item .form-group {
    min-width: 0;
    /* Allow items to shrink below their content width */
    overflow: hidden;
}

.history-row-item .form-group input {
    min-width: 0;
    /* Allow input itself to shrink */
}

/* =========================================================
   2. Resume A4 Document Styles (JIS Standard Mockup)
========================================================= */
/* Preview Box - Vertical Stacking */
.resume-preview-box {
    width: 100%;
    background: #e9ecef;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: flex-start;
    /* Align to left where the scaled content starts */
    justify-content: flex-start;
    border-radius: 8px;
    box-sizing: border-box;
    overflow: hidden;
}

/* Scaling Wrapper */
.preview-scale-container {
    width: 100%;
    /* Will be overridden by JS */
    display: flex;
    justify-content: flex-start;
    /* Ensure the scaled origin (left) aligns perfectly */
    align-items: flex-start;
    overflow: visible;
    /* Let the scaled child be visible */
    position: relative;
}

.a4-document {
    /* 
       A4 Ratio: 1:1.414. We set a fixed width of ~794px for consistent 
       canvas rendering, which scales well to A4 (210x297mm) at JS side.
    */
    width: 794px !important;
    height: 1123px !important;
    min-width: 794px;
    min-height: 1123px;
    background: white;
    padding: 40px;
    box-sizing: border-box;
    font-family: 'Noto Sans JP', serif;
    /* A formal font for resumes */
    color: #000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    transform-origin: top left;
    /* Critical: scales from top-left so it stays within the adjusted width footprint */
}

/* Base structural setups */
.a4-document table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    border: 1.5px solid #000;
}

.a4-document th,
.a4-document td {
    border: 1.5px solid #000;
    padding: 8px;
    font-size: 14px;
    line-height: 1.4;
    color: #000;
}

.a4-document .label {
    background-color: #fff;
    /* Keep white for printing */
    text-align: center;
    vertical-align: middle;
    font-weight: 400;
}

/* Header Section */
.cv-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.cv-title-date {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.cv-title-date h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 1.5em;
    /* Spaced out 履 歴 書 */
    margin: 0 0 10px 0;
}

.cv-title-date .date-box {
    text-align: right;
    font-size: 14px;
    padding-right: 20px;
}

.cv-photo-box {
    width: 30mm;
    height: 40mm;
    border: 1px dotted #666;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 20px;
    text-align: center;
    font-size: 12px;
    color: #999;
}

/* Basic Info Table Overrides */
.cv-table-basic .col-furi {
    width: 15%;
    text-align: left;
    border-bottom: 1px dotted #ccc;
    padding-bottom: 3px;
    font-size: 11px;
}

.cv-table-basic .val-furi {
    border-bottom: 1px dotted #ccc;
    padding-bottom: 3px;
    font-size: 12px;
}

.cv-table-basic .col-name {
    text-align: left;
    vertical-align: middle;
    height: 60px;
    font-size: 12px;
}

.cv-table-basic .val-name {
    font-size: 24px;
    font-weight: bold;
}

.cv-table-basic .val-dob {
    text-align: center;
    font-size: 14px;
}

.cv-table-basic .address-row .label {
    vertical-align: top;
    font-size: 12px;
}

.cv-table-basic .val-address {
    height: 60px;
    vertical-align: top;
}

/* History Table Overrides */
.cv-table-history th {
    text-align: center;
    border-bottom: 2px solid #000;
}

.cv-table-history .col-y {
    width: 12%;
}

.cv-table-history .col-m {
    width: 8%;
}

.cv-table-history .col-c {
    width: 80%;
}

.cv-table-history tbody td {
    height: 28px;
    padding: 4px 8px;
}

.cv-table-history tbody .val-y,
.cv-table-history tbody .val-m {
    text-align: center;
}

/* Print Mode Adjustments (crucial for html2canvas) */
@media print {
    .panel {
        box-shadow: none;
        border: none;
    }

    .config-panel,
    .preview-actions,
    .helper-text {
        display: none !important;
    }

    .resume-container {
        margin: 0;
        display: block;
    }

    body,
    html {
        background: white;
    }
}