@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
    --primary-color: #2c5282; /* Professional blue-gray */
    --primary-light: #4299e1;
    --primary-dark: #1a365d;
    --secondary-color: #4a5568;
    --background-color: #f7fafc;
    --surface-color: #ffffff;
    --text-main: #2d3748;
    --text-muted: #718096;
    
    --success-color: #48bb78;
    --success-hover: #38a169;
    --error-color: #e53e3e;
    --warning-color: #dd6b20;
    --info-color: #3182ce;
    
    --border-color: #e2e8f0;
    --dropzone-border: #cbd5e0;
    --dropzone-bg: #ebf8ff;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    
    --spacing-1: 0.25rem;
    --spacing-2: 0.5rem;
    --spacing-3: 0.75rem;
    --spacing-4: 1rem;
    --spacing-6: 1.5rem;
    --spacing-8: 2rem;
    --spacing-12: 3rem;
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    background-color: var(--background-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    font-weight: 700;
    color: var(--primary-dark);
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.hidden {
    display: none !important;
}

/* Header */
header {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-4) var(--spacing-6);
    text-align: center;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
}

header h1 {
    font-size: 1.75rem;
    margin-bottom: var(--spacing-1);
    color: var(--primary-color);
}

.tagline {
    font-size: 0.875rem;
    color: var(--secondary-color);
    font-weight: 500;
}

/* Main Layout */
.page-layout {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
}

.sidebar-ad {
    display: none; /* Hidden on mobile */
}

@media (min-width: 1200px) {
    .sidebar-ad {
        display: block;
        width: 160px; /* Standard sidebar ad width */
        flex-shrink: 0;
        margin-top: 2rem;
        position: sticky;
        top: 20px;
        height: fit-content;
    }
}

main {
    flex: 1;
    max-width: 960px;
    width: 100%;
    padding: var(--spacing-8) var(--spacing-4);
}

section {
    margin-bottom: var(--spacing-12);
}

section > h2 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-6);
    padding-bottom: var(--spacing-2);
    border-bottom: 2px solid var(--border-color);
}

/* Features Section */
.features-section {
    margin-bottom: var(--spacing-8);
}
.features-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-4);
}
@media (min-width: 768px) {
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
.feature-card {
    background: var(--surface-color);
    padding: var(--spacing-6);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border-top: 4px solid var(--primary-light);
    text-align: center;
}
.feature-icon {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-3);
}
.feature-card h3 {
    font-size: 1.1rem;
    margin-bottom: var(--spacing-2);
}
.feature-card p {
    font-size: 0.9rem;
    color: var(--secondary-color);
    text-align: left;
}

/* Security Flowchart */
.security-section {
    background-color: #ebf8ff;
    padding: var(--spacing-6);
    border-radius: var(--radius-lg);
    border: 1px solid #bee3f8;
    margin-bottom: var(--spacing-8);
}
.security-desc {
    font-size: 0.95rem;
    margin-bottom: var(--spacing-6);
    text-align: center;
}
.flowchart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-2);
}
@media (min-width: 768px) {
    .flowchart {
        flex-direction: row;
        justify-content: space-between;
        align-items: stretch;
    }
}
.flow-step {
    background: white;
    padding: var(--spacing-4);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    flex: 1;
    text-align: center;
    border: 2px solid transparent;
    width: 100%;
}
.flow-step.highlight {
    border-color: var(--success-color);
    background-color: #f0fff4;
}
.flow-icon {
    font-size: 2rem;
    margin-bottom: var(--spacing-2);
}
.flow-title {
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: var(--spacing-2);
}
.flow-text {
    font-size: 0.85rem;
    color: var(--secondary-color);
}
.flow-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-light);
    padding: var(--spacing-2);
}
@media (max-width: 767px) {
    .flow-arrow {
        transform: rotate(90deg);
    }
}

/* Converter Section */
.converter-section {
    margin-top: var(--spacing-4);
}

.converter-card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-8);
    border: 1px solid var(--border-color);
}

.mode-selector {
    margin-bottom: var(--spacing-6);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
}

.mode-selector label {
    font-weight: 700;
    font-size: 1rem;
}

.mode-selector select {
    padding: var(--spacing-3);
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--surface-color);
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s;
}

.mode-selector select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--dropzone-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-12) var(--spacing-6);
    text-align: center;
    background-color: #fafbfc;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    margin-bottom: var(--spacing-6);
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary-light);
    background-color: var(--dropzone-bg);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-4);
    pointer-events: none;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--primary-light);
}

.drop-zone p {
    color: var(--secondary-color);
    font-weight: 500;
}

.file-input {
    display: none;
}

.btn-select-file {
    pointer-events: auto;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: var(--spacing-2) var(--spacing-6);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-select-file:hover {
    background-color: var(--primary-dark);
}

/* Drag Over State */
.drop-zone.drag-over {
    border-color: var(--primary-light);
    background-color: var(--dropzone-bg);
    box-shadow: 0 0 0 4px rgba(66, 153, 225, 0.15);
}

/* Conversion Description */
.conversion-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: var(--spacing-1);
}

/* Convert Action */
.convert-action {
    text-align: center;
    margin-bottom: var(--spacing-6);
}

.btn-convert {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-2);
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: var(--spacing-3) var(--spacing-8);
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-md);
    min-width: 200px;
}

.btn-convert:hover:not(:disabled) {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-convert:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-convert.ready {
    background-color: #2b6cb0;
    animation: pulse-ready 2s infinite;
}

@keyframes pulse-ready {
    0%, 100% { box-shadow: var(--shadow-md); }
    50% { box-shadow: 0 0 0 4px rgba(66, 153, 225, 0.3); }
}

/* Log Entry Styles */
.log-entry {
    margin-bottom: var(--spacing-1);
    padding-bottom: var(--spacing-1);
    border-bottom: 1px solid #2d3748;
    display: flex;
    gap: var(--spacing-2);
    align-items: flex-start;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: #4a5568;
    flex-shrink: 0;
    font-size: 0.8rem;
}

.log-icon {
    flex-shrink: 0;
}

.log-message {
    flex: 1;
    word-break: break-word;
}

.log-info .log-message { color: #63b3ed; }
.log-success .log-message { color: #68d391; }
.log-error .log-message { color: #fc8181; }
.log-warning .log-message { color: #fbd38d; }

/* File Info */
.file-info {
    background-color: #f7fafc;
    padding: var(--spacing-3) var(--spacing-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: var(--spacing-6);
    font-size: 0.9rem;
    color: var(--secondary-color);
}

/* Progress & Ad Area */
.ad-progress-area {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-6);
    margin-bottom: var(--spacing-6);
}

@media (min-width: 768px) {
    .ad-progress-area {
        flex-direction: row;
        align-items: center;
    }
    
    .progress-container {
        flex: 1;
    }
    
    .ad-placeholder-small {
        width: 300px;
        flex-shrink: 0;
    }
}

.progress-container {
    width: 100%;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background-color: var(--border-color);
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: var(--spacing-2);
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-light);
    width: 0%;
    transition: width 0.3s ease;
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    );
    background-size: 1rem 1rem;
    animation: progress-stripes 1s linear infinite;
}

@keyframes progress-stripes {
    from { background-position: 1rem 0; }
    to { background-position: 0 0; }
}

.progress-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: right;
}

.ad-mockup {
    background: #e2e8f0;
    border: 1px dashed #a0aec0;
    color: #718096;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 90px; /* Standard Adsense Mobile Banner height */
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

/* Result Area */
.result-area {
    text-align: center;
    margin-bottom: var(--spacing-6);
    padding: var(--spacing-6) 0;
    border-top: 1px solid var(--border-color);
}

.btn-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-2);
    background-color: var(--success-color);
    color: white;
    border: none;
    padding: var(--spacing-4) var(--spacing-8);
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 400px;
}

.btn-download:hover {
    background-color: var(--success-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Status Log */
.status-log {
    max-height: 150px;
    overflow-y: auto;
    border-radius: var(--radius-md);
    padding: var(--spacing-3);
    background-color: #1a202c; /* Dark background for console feel */
    color: #a0aec0;
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 0.85rem;
}

.status-msg {
    margin-bottom: var(--spacing-1);
    padding-bottom: var(--spacing-1);
    border-bottom: 1px solid #2d3748;
}

.status-msg:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.msg-info { color: #63b3ed; }
.msg-success { color: #68d391; }
.msg-error { color: #fc8181; }
.msg-warning { color: #fbd38d; }

/* Dynamic Ad Grid for Rakuten Affiliate */
.dynamic-ad-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-4);
    justify-content: center;
}

.ad-slot {
    flex: 1 1 480px;
    max-width: 100%;
    display: flex;
    justify-content: center;
}

/* 楽天アフィリエイトのインラインスタイル（固定幅）を強制的に上書きしてレスポンシブ化 */
.ad-slot > table,
.ad-slot > table > tbody > tr > td > div,
.ad-slot > table > tbody > tr > td > div > table {
    width: 100% !important;
    max-width: 504px !important; /* 楽天の最大幅 */
    box-sizing: border-box !important;
}

/* スマホ等（幅540px以下）での縦並び化強制 */
@media (max-width: 540px) {
    .ad-slot > table > tbody > tr > td > div > table > tbody > tr {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }
    
    .ad-slot > table > tbody > tr > td > div > table > tbody > tr > td {
        width: 100% !important;
        display: block !important;
        text-align: center !important;
    }
    
    /* 画像とテキストの間に余白 */
    .ad-slot > table > tbody > tr > td > div > table > tbody > tr > td:first-child {
        margin-bottom: 12px;
    }
}

.affiliate-links {
    display: flex;
    gap: var(--spacing-2);
}

.btn-affiliate {
    flex: 1;
    text-align: center;
    padding: var(--spacing-2);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
    color: white !important;
    text-decoration: none !important;
}

.btn-affiliate.amazon { background-color: #f3a847; color: #111 !important; }
.btn-affiliate.rakuten { background-color: #bf0000; }

/* SEO Articles Section */
.seo-articles {
    background: white;
    padding: var(--spacing-8);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-12);
}

.section-intro {
    font-size: 1.1rem;
    color: var(--secondary-color);
    margin-bottom: var(--spacing-8);
    text-align: center;
}

.seo-article {
    margin-bottom: var(--spacing-8);
    padding-bottom: var(--spacing-6);
    border-bottom: 1px solid var(--border-color);
}

.seo-article:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.seo-article h3 {
    font-size: 1.4rem;
    color: var(--primary-color);
    margin-bottom: var(--spacing-4);
    position: relative;
    padding-left: var(--spacing-4);
}

.seo-article h3::before {
    content: '';
    position: absolute;
    left: 0;
    top: 5px;
    bottom: 5px;
    width: 4px;
    background-color: var(--primary-light);
    border-radius: 2px;
}

.seo-article p {
    margin-bottom: var(--spacing-3);
    line-height: 1.8;
}

.seo-article strong {
    color: var(--primary-dark);
    background: linear-gradient(transparent 70%, rgba(66, 153, 225, 0.2) 70%);
}

/* Career Banner */
.career-section {
    text-align: center;
}

.banner-placeholder {
    background: #e2e8f0;
    border: 1px dashed #a0aec0;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #718096;
    border-radius: var(--radius-md);
}

/* Footer */
footer {
    background-color: var(--primary-dark);
    color: #cbd5e0;
    padding: var(--spacing-8) var(--spacing-4);
    text-align: center;
    margin-top: auto;
}

.footer-content {
    max-width: 960px;
    margin: 0 auto;
}

.privacy-notice {
    font-size: 0.9rem;
    margin-bottom: var(--spacing-4);
    color: #e2e8f0;
}

.footer-nav {
    display: flex;
    justify-content: center;
    gap: var(--spacing-6);
    margin-bottom: var(--spacing-6);
}

.footer-nav a {
    color: #a0aec0;
    font-size: 0.9rem;
}

.footer-nav a:hover {
    color: white;
}

.copyright {
    font-size: 0.8rem;
    color: #718096;
}

/* Print Styles */
@media print {
    header, footer, .recommendations-section, .career-section {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .converter-card {
        box-shadow: none;
        border: 1px solid #000;
    }
}
