/* リセットとベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #e2e8f0;
    background: linear-gradient(135deg, #0e1118 0%, #1b222c 50%, #41211e 100%);
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ヘッダー */
.header {
    text-align: center;
    margin-bottom: 20px;
    background: rgba(111, 59, 52, 0.2);
    backdrop-filter: blur(5px);
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid rgba(115, 61, 53, 0.3);
}

.header h1 {
    color: white;
    font-size: 1.8rem;
    margin-bottom: 5px;
    font-weight: 600;
}

.header p {
    color: rgba(226, 232, 240, 0.8);
    font-size: 0.9rem;
}

/* メインコンテンツ */
.main {
    flex: 1;
    background: #1a202c;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid #2d3748;
}

/* アップロードセクション */
.upload-section {
    margin-bottom: 30px;
}

.file-drop-zone {
    border: 3px dashed #C93C12;
    border-radius: 15px;
    padding: 60px 20px;
    text-align: center;
    background: rgba(201, 60, 18, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.file-drop-zone:hover {
    border-color: #E8471C;
    background: rgba(201, 60, 18, 0.15);
    box-shadow: 0 8px 25px rgba(201, 60, 18, 0.25);
}

.file-drop-zone.drag-over {
    border-color: #FF5722;
    background: rgba(201, 60, 18, 0.2);
    box-shadow: 0 12px 35px rgba(201, 60, 18, 0.35);
    border-style: solid;
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.upload-icon {
    width: 60px;
    height: 60px;
    color: #C93C12;
    margin-bottom: 10px;
}

.drop-zone-content h3 {
    font-size: 1.5rem;
    color: #e2e8f0;
    margin-bottom: 5px;
}

.drop-zone-content p {
    color: #a0aec0;
    font-size: 1rem;
    margin-bottom: 10px;
}

/* ボタンスタイル */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #C93C12 0%, #E8471C 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(201, 60, 18, 0.4);
}

.btn-secondary {
    background: #4a5568;
    color: #e2e8f0;
}

.btn-secondary:hover:not(:disabled) {
    background: #2d3748;
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(72, 187, 120, 0.3);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(245, 158, 11, 0.3);
}

.btn-info {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.btn-info:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(72, 187, 120, 0.3);
}

.btn-small {
    padding: 6px 16px;
    font-size: 0.9rem;
}

.select-files-btn {
    background: linear-gradient(135deg, #9b3515 0%, #ae3615 100%);
    color: white;
    padding: 15px 30px;
    font-size: 1.1rem;
}

.select-files-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(201, 60, 18, 0.4);
}

/* ファイルリストセクション */
.files-section {
    margin-bottom: 30px;
}

.files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.files-section h2 {
    font-size: 1.5rem;
    margin: 0;
    color: #e2e8f0;
}

.bulk-paper-size-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(72, 187, 120, 0.1);
    padding: 8px 15px;
    border-radius: 8px;
    border: 1px solid rgba(72, 187, 120, 0.3);
}

.bulk-paper-size-control label {
    font-size: 0.9rem;
    color: #a0aec0;
    white-space: nowrap;
}

.bulk-paper-size-select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #4a5568;
    background: #1a202c;
    color: #e2e8f0;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.bulk-paper-size-select:hover {
    border-color: #48bb78;
    background: #0f1419;
}

.bulk-paper-size-select:focus {
    outline: none;
    border-color: #48bb78;
    box-shadow: 0 0 0 3px rgba(72, 187, 120, 0.2);
}

.files-list {
    background: #1a202c;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    min-height: 100px;
    border: 1px solid #2d3748;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #0f1419;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border: 1px solid #2d3748;
    cursor: grab;
    user-select: none;
    transition: all 0.2s ease;
}

.file-item:active {
    cursor: grabbing;
}

.file-item.dragging {
    opacity: 0.8;
    transform: scale(1.03);
    box-shadow: 0 15px 35px rgba(201, 60, 18, 0.3), 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    border: 2px solid #C93C12;
    background: rgba(201, 60, 18, 0.1);
}

.file-item.dragging .file-actions {
    opacity: 0.3;
}

.file-item.drag-over {
    border-color: #C93C12;
    background: rgba(201, 60, 18, 0.2);
    transform: translateY(-2px);
}

.file-item.drag-insert-top {
    position: relative;
}

.file-item.drag-insert-top::before {
    content: '';
    position: absolute;
    top: -8px;
    left: -10px;
    right: -10px;
    height: 6px;
    background: linear-gradient(90deg, #C93C12, #E8471C, #FF5722);
    border-radius: 3px;
    box-shadow: 0 0 15px rgba(201, 60, 18, 0.8), 0 0 30px rgba(201, 60, 18, 0.4);
    z-index: 10;
    animation: insertIndicator 1s ease-in-out infinite alternate;
}

.file-item.drag-insert-bottom {
    position: relative;
}

.file-item.drag-insert-bottom::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: -10px;
    right: -10px;
    height: 6px;
    background: linear-gradient(90deg, #C93C12, #E8471C, #FF5722);
    border-radius: 3px;
    box-shadow: 0 0 15px rgba(201, 60, 18, 0.8), 0 0 30px rgba(201, 60, 18, 0.4);
    z-index: 10;
    animation: insertIndicator 1s ease-in-out infinite alternate;
}

@keyframes insertIndicator {
    from {
        opacity: 0.8;
        transform: scaleY(0.7) scaleX(0.95);
        box-shadow: 0 0 10px rgba(201, 60, 18, 0.6), 0 0 20px rgba(201, 60, 18, 0.3);
    }
    to {
        opacity: 1;
        transform: scaleY(1.3) scaleX(1.05);
        box-shadow: 0 0 20px rgba(201, 60, 18, 1), 0 0 40px rgba(201, 60, 18, 0.6);
    }
}

@keyframes pulse {
    from {
        opacity: 0.6;
        transform: scaleY(0.8);
    }
    to {
        opacity: 1;
        transform: scaleY(1.2);
    }
}

/* ドラッグ中のファイルリスト全体のスタイル */
.files-list.drag-active {
    background: rgba(201, 60, 18, 0.08);
    border: 2px dashed rgba(201, 60, 18, 0.3);
    border-radius: 8px;
    box-shadow: inset 0 0 20px rgba(201, 60, 18, 0.1);
}

/* より目立つドロップゾーンインジケーター */
.file-item.drag-drop-zone {
    background: linear-gradient(135deg, rgba(201, 60, 18, 0.2), rgba(232, 71, 28, 0.25));
    border: 3px dashed #C93C12;
    transform: scale(1.03);
    box-shadow: 0 10px 30px rgba(201, 60, 18, 0.4), inset 0 0 20px rgba(201, 60, 18, 0.1);
    position: relative;
    animation: dropZonePulse 1.5s ease-in-out infinite alternate;
}

.file-item.drag-drop-zone::before {
    content: '↕ 入れ替え';
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #C93C12, #E8471C);
    color: white;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 700;
    z-index: 5;
    box-shadow: 0 4px 12px rgba(201, 60, 18, 0.5);
    animation: swapIndicator 0.8s ease-in-out infinite alternate;
}

@keyframes dropZonePulse {
    from {
        background: linear-gradient(135deg, rgba(201, 60, 18, 0.15), rgba(232, 71, 28, 0.2));
        box-shadow: 0 8px 25px rgba(201, 60, 18, 0.3), inset 0 0 15px rgba(201, 60, 18, 0.05);
    }
    to {
        background: linear-gradient(135deg, rgba(201, 60, 18, 0.25), rgba(232, 71, 28, 0.3));
        box-shadow: 0 15px 35px rgba(201, 60, 18, 0.5), inset 0 0 25px rgba(201, 60, 18, 0.15);
    }
}

@keyframes swapIndicator {
    from {
        opacity: 0.8;
        transform: translateY(-50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) scale(1.05);
    }
}

.file-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: #fed7d7;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #c53030;
    font-size: 0.8rem;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.file-icon:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.file-icon-container {
    position: relative;
    display: inline-block;
}

.file-icon-container::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 5;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>');
    background-size: 14px 14px;
    background-repeat: no-repeat;
    background-position: center;
}

.file-icon-container:hover::after {
    opacity: 1;
}

.file-thumbnail {
    display: flex;
    gap: 4px;
    cursor: pointer;
    position: relative;
}

.thumbnail-item {
    position: relative;
    display: inline-block;
}

.thumbnail-page {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.thumbnail-page:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.thumbnail-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.thumbnail-item:hover .thumbnail-overlay {
    opacity: 1;
}

.thumbnail-eye-icon {
    width: 20px;
    height: 20px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
}

/* 複数のサムネイルがある場合の2つ目のサムネイルにわずかに重ねる効果 */
.file-thumbnail .thumbnail-item:nth-child(2) {
    margin-left: -4px;
    position: relative;
    z-index: 1;
}

.file-thumbnail-container {
    position: relative;
    display: inline-block;
}

.file-details h4 {
    font-size: 1rem;
    color: #e2e8f0;
    margin-bottom: 2px;
}

.file-details p {
    font-size: 0.9rem;
    color: #a0aec0;
}

.file-actions {
    display: flex;
    gap: 10px;
}

.file-move-btn {
    background: #2d3748;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #e2e8f0;
}

.file-move-btn:hover {
    background: #1a202c;
}

.file-remove-btn {
    background: rgba(201, 60, 18, 0.2);
    color: #FF8A65;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.file-remove-btn:hover {
    background: rgba(201, 60, 18, 0.3);
    color: #FF7043;
}

.actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* プログレスセクション */
.progress-section {
    margin-bottom: 30px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #1a202c;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
    border: 1px solid #2d3748;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #C93C12 0%, #E8471C 100%);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.progress-text {
    font-size: 1.1rem;
    color: #e2e8f0;
    font-weight: 600;
}

/* 結果セクション */
.result-section {
    text-align: center;
}

.result-card {
    background: rgba(201, 60, 18, 0.1);
    border: 2px solid #C93C12;
    border-radius: 15px;
    padding: 40px;
}

.result-card h3 {
    font-size: 1.8rem;
    color: #C93C12;
    margin-bottom: 15px;
}

.result-card p {
    font-size: 1.1rem;
    color: #e2e8f0;
    margin-bottom: 25px;
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.result-card .btn {
    margin: 0;
    min-width: 180px;
}

/* フッター */
.footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    background: rgba(134, 71, 63, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    border: 1px solid rgba(134, 71, 63, 0.3);
}

.footer p {
    color: rgba(226, 232, 240, 0.8);
    font-size: 0.9rem;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .main {
        padding: 25px;
    }
    
    .file-drop-zone {
        padding: 40px 15px;
    }
    
    .file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .file-actions {
        align-self: stretch;
        justify-content: flex-end;
    }
      .actions {
        flex-direction: column;
    }
    
    .result-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .result-card .btn {
        margin: 0;
        width: 100%;
        min-width: auto;
    }
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* モーダルウィンドウのスタイル */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: #1a202c;
    border-radius: 15px;
    max-width: 90vw;
    max-height: 90vh;
    width: 800px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    border: 1px solid #2d3748;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #2d3748;
    background: rgba(134, 71, 63, 0.15);
}

.modal-header h3 {
    color: #e2e8f0;
    font-size: 1.2rem;
    margin: 0;
    max-width: calc(100% - 40px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: #a0aec0;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: #2d3748;
    color: #e2e8f0;
}

.modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.preview-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 15px 25px;
    border-bottom: 1px solid #2d3748;
    background: rgba(134, 71, 63, 0.15);
    flex-wrap: wrap;
}

.preview-controls .btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-jump::before {
    font-size: 0.8rem;
}

.btn-jump.first::before {
    content: '⏮';
}

.btn-jump.last::before {
    content: '⏭';
}

#pageInfo {
    font-weight: 600;
    color: #e2e8f0;
    min-width: 60px;
    text-align: center;
}

.zoom-select {
    padding: 8px 12px;
    border: 1px solid #2d3748;
    border-radius: 6px;
    background: #1a202c;
    color: #e2e8f0;
    font-size: 0.9rem;
    cursor: pointer;
}

.preview-canvas-container {
    flex: 1;
    overflow: auto;
    padding: 20px;
    background: #0f1419;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.preview-page {
    border: 1px solid #2d3748;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    background: white;
    max-width: 100%;
    position: relative;
}

.preview-page-number {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: #C93C12;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 10;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .modal-content {
        width: 95vw;
        height: 90vh;
    }
    
    .preview-controls {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 15px;
    }
    
    .preview-controls .btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .preview-canvas-container {
        padding: 15px;
    }
}

/* 用紙サイズ選択 */
.paper-size-selector {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.paper-size-selector label {
    font-size: 0.85rem;
    color: #a0aec0;
    white-space: nowrap;
}

.paper-size-select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #4a5568;
    background: #1a202c;
    color: #e2e8f0;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.paper-size-select:hover {
    border-color: #C93C12;
    background: #0f1419;
}

.paper-size-select:focus {
    outline: none;
    border-color: #E8471C;
    box-shadow: 0 0 0 3px rgba(201, 60, 18, 0.2);
}

/* ファイルタイプバッジ */
.file-type-badge {
    display: inline-block;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    font-weight: 600;
    vertical-align: middle;
}
