/* app/static/css/app.css - Modern styles for Kaname Learning */

/* CSS Variables for Modern Design */
	:root {
	    --primary-color: #6366f1;
	    --primary-light: #8b5cf6;
	    --primary-dark: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
	    --info-color: #06b6d4;
	    --dark-color: #1e293b;
	    --light-color: #f8fafc;
	    --sidebar-width: 240px;
	    /* 小画面（タブレット/スマホ）用: ドロワー幅は可変にして余白を確保 */
	    --sidebar-width-mobile: min(88vw, 360px);

    /* New modern colors */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-success: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-sidebar: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);

    /* Shadows */
    --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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Base styles */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: #374151;
}

/* Modern Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    width: var(--sidebar-width);
    background: var(--gradient-sidebar);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-xl);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-content {
    padding-top: 1.5rem;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-header h4 {
    font-weight: 700;
    font-size: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.sidebar-header small {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    font-size: 0.875rem;
}

/* 視認性を高めた管理者パネルバッジ */
.admin-panel-chip {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    margin-top: 0.4rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%);
    color: #1a202c;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 10px rgba(250, 208, 196, 0.35);
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.8);
    padding: 0.875rem 1.25rem;
    margin: 0.25rem 0.5rem;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    transform: translateX(4px);
}

.sidebar .nav-link.active {
    color: #fff;
    background: var(--gradient-primary);
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #fff;
    border-radius: 0 2px 2px 0;
}

.sidebar .nav-link i {
    font-size: 1.125rem;
    width: 1.5rem;
    text-align: center;
}

.sidebar-footer {
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer small {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
}

	/* Main content area */
	main {
	    min-height: 100vh;
	    padding: 0;
	    background: transparent;
	}

	/* レイアウト: 固定サイドバーとメインの重なりを防ぐ */
	.app-main {
	    flex: 1 1 auto;
	    width: 100%;
	    max-width: 100%;
	    min-width: 0;
	}

	@media (min-width: 992px) {
	    .app-main {
	        /* サイドバーが fixed のため、メイン側を明示的にオフセットする */
	        margin-left: var(--sidebar-width);
	        width: calc(100% - var(--sidebar-width));
	    }
	}

	/* 小画面時のサイドバー用オーバーレイ */
	.sidebar-backdrop {
	    display: none;
	    position: fixed;
	    inset: 0;
	    background: rgba(15, 23, 42, 0.45);
	    backdrop-filter: blur(2px);
	    z-index: 1040;
	    opacity: 0;
	    pointer-events: none;
	    transition: opacity 0.2s ease;
	}

/* Top bar */
.main-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

/* トップバーのアクション群: 高さが伸びて見えないように揃える */
.topbar-actions {
    align-items: center;
}

.main-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--dark-color);
    margin: 0;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 修正: タイトル行内のバッジはグラデーション文字の影響を受けないようにリセット */
.main-header h1 .badge {
    -webkit-text-fill-color: currentColor !important;
    /* Safari系の透明文字を打ち消す */
    color: #212529 !important;
    /* text-dark と同等 */
    background-color: #f8f9fa !important;
    /* bg-light と同等 */
    border: 1px solid rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
    /* 念のため前面に表示 */
    box-shadow: none;
    /* 文字が潰れて見えるのを防ぐ */
}

/* Cards with modern design */
.card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

/* Report progress banner */
.progress-banner {
    position: relative;
    padding: 1.5rem 1.75rem;
    border-radius: 26px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    color: #0f172a;
    background: #ffffff;
    transition: all 0.3s ease;
}

.progress-banner::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 26px;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.progress-banner--transcribing {
    background: linear-gradient(120deg, #312e81, #4338ca 45%, #6366f1);
    color: #f8fafc;
    border-color: rgba(99, 102, 241, 0.3);
}

.progress-banner--building {
    background: linear-gradient(120deg, #0f766e, #14b8a6 55%, #2dd4bf);
    color: #ecfeff;
    border-color: rgba(45, 212, 191, 0.3);
}

.progress-banner--done {
    background: linear-gradient(120deg, #15803d, #22c55e 55%, #6ee7b7);
    color: #ecfdf5;
    border-color: rgba(134, 239, 172, 0.5);
}

.progress-banner--error {
    background: linear-gradient(120deg, #991b1b, #dc2626 55%, #f87171);
    color: #fff5f5;
    border-color: rgba(248, 113, 113, 0.5);
}

.progress-banner__head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.progress-banner__eyebrow {
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.9;
    margin-bottom: 0.25rem;
}

.progress-banner__title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.progress-banner__body {
    font-size: 0.95rem;
    opacity: 0.95;
}

.progress-banner__status {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 3rem;
}

.progress-banner__status .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

.progress-banner__progress .progress {
    height: 10px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 999px;
}

.progress-banner__progress .progress-bar {
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    color: #0f172a;
}

.progress-banner--transcribing .progress-bar {
    color: #1e1b4b;
}

.progress-banner__error {
    background: rgba(15, 23, 42, 0.35);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    line-height: 1.6;
}

.progress-banner__error strong {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
}

.progress-thin {
    height: 10px;
    border-radius: 999px;
}

.card-header {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 1.5rem 2rem;
    border-radius: 20px 20px 0 0;
    position: relative;
    overflow: hidden;
}

.card-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.card-header h5,
.card-header h6 {
    margin: 0;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.card-body {
    padding: 2rem;
}

/* Modern Buttons */
.btn {
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    border: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: none;
    font-size: 0.875rem;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* 強調: 音声アップロード用CTAボタン */
.btn-upload-cta {
    /* 青系のデフォルト（primary）へ統一 */
    background: var(--gradient-primary);
    color: #fff !important;
    padding: 0.85rem 1.4rem;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(79, 70, 229, 0.25);
    /* primary-dark */
    border: none;
    width: auto;
    max-width: 320px;
    /* カード幅より短く */
}

.btn-upload-cta:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 14px 32px rgba(79, 70, 229, 0.35);
}

.btn-upload-cta:disabled {
    opacity: 0.8;
    filter: saturate(0.9) brightness(0.95);
}

/* Grid内でもボタン幅が広がらないように中央揃え */
.d-grid .btn-upload-cta {
    justify-self: center;
}

.btn-success {
    background: var(--gradient-success);
    color: white;
    box-shadow: var(--shadow-md);
}

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

.btn-outline-primary:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* 印刷ボタンなど、Bootstrap outline-secondary を正常に戻す */
.btn-outline-secondary {
    border: 2px solid #6c757d !important;
    /* グレー枠 */
    color: #6c757d !important;
    background: transparent !important;
}

.btn-outline-secondary:hover {
    background: #6c757d !important;
    /* ホバーでグレー反転 */
    color: #ffffff !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}


/* 明示的に赤枠を強調（Bootstrapのoutline-dangerが見えづらい環境向け） */
.btn-outline-danger {
    border: 2px solid var(--danger-color) !important;
    color: var(--danger-color) !important;
    background: transparent !important;
}

.btn-outline-danger:hover {
    background: var(--danger-color) !important;
    color: #ffffff !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Status badges with glow effect */
.badge {
    font-size: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-sm);
}

.badge.bg-success {
    background: var(--gradient-success) !important;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.badge.bg-danger {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52) !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.badge.bg-warning {
    background: linear-gradient(135deg, #ffd93d, #ff9f43) !important;
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
    color: #1a202c !important;
}

.badge.bg-info {
    background: linear-gradient(135deg, #14b8a6, #0d9488) !important;
    /* teal系に変更: UPLOADING専用に視認性向上 */
    box-shadow: 0 0 20px rgba(13, 148, 136, 0.3);
}

/* 追加: ステータス専用の明確色バッジ（似た色を避ける） */
.badge-uploading {
    background: linear-gradient(135deg, #14b8a6, #0d9488) !important;
    color: #ffffff !important;
    box-shadow: 0 0 20px rgba(13, 148, 136, .3);
}

.badge-running {
    background: linear-gradient(135deg, #ffd93d, #ff9f43) !important;
    color: #1a202c !important;
    box-shadow: 0 0 20px rgba(245, 158, 11, .3);
}

.badge-done {
    background: linear-gradient(135deg, #22c55e, #16a34a) !important;
    color: #ffffff !important;
    box-shadow: 0 0 20px rgba(34, 197, 94, .3);
}

.badge-error {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: #ffffff !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, .3);
}

.badge-partial {
    background: linear-gradient(135deg, #a78bfa, #7c3aed) !important;
    color: #ffffff !important;
    box-shadow: 0 0 20px rgba(124, 58, 237, .3);
}

.badge-secondary-strong {
    background: linear-gradient(135deg, #94a3b8, #64748b) !important;
    color: #111827 !important;
}

/* Modern Table */
.table {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.table thead th {
    background: rgba(99, 102, 241, 0.1);
    border: none;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem;
}

.table tbody td {
    border: none;
    padding: 1rem;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* Toasts: ほかのUIより前面に出す（レイアウト影響なし） */
.toast-container {
    z-index: 1080;
}

/* Modern Forms */
.form-control {
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25);
    background: white;
}

.form-label {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

/* File upload with modern styling */
.form-control[type="file"] {
    padding: 1.5rem;
    background: linear-gradient(145deg, #f8fafc, #ffffff);
    border: 2px dashed var(--primary-color);
    border-radius: 16px;
    text-align: center;
    position: relative;
    transition: all 0.3s ease;
}

.form-control[type="file"]:hover {
    background: linear-gradient(145deg, #e2e8f0, #f8fafc);
    border-color: var(--primary-dark);
    transform: scale(1.02);
}

/* Modern Alerts */
.alert {
    border: none;
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
    border-left: 4px solid var(--success-color);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #7f1d1d;
    border-left: 4px solid var(--danger-color);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #78350f;
    border-left: 4px solid var(--warning-color);
}

.alert-info {
    background: rgba(6, 182, 212, 0.1);
    color: #0c4a6e;
    border-left: 4px solid var(--info-color);
}

/* Modern Progress */
.progress {
    height: 8px;
    border-radius: 50px;
    background: rgba(0, 0, 0, 0.1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    border-radius: 50px;
    background: var(--gradient-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Empty state styling */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    margin: 2rem 0;
}

.empty-state i {
    font-size: 4rem;
    color: var(--primary-color);
    opacity: 0.5;
    margin-bottom: 1.5rem;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Loading states */
.loading-shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

	/* Responsive Design */
@media (max-width: 991.98px) {
	    /* 小画面ではサイドバーをドロワー化して、本文との重なり/隠れを根本解消する */
	    .sidebar {
	        width: var(--sidebar-width-mobile);
	        transform: translateX(-110%);
	        z-index: 1050;
	        visibility: hidden;
	        pointer-events: none;
	    }

	    .sidebar.show {
	        transform: translateX(0);
	        visibility: visible;
	        pointer-events: auto;
	    }

	    body.sidebar-open {
	        overflow: hidden;
	    }

	    .sidebar-backdrop {
	        display: block;
	    }

	    body.sidebar-open .sidebar-backdrop {
	        opacity: 1;
	        pointer-events: auto;
	    }

	    .main-header {
	        padding: 1rem;
	    }

	    .card-body {
	        padding: 1.5rem;
	    }

	    .btn-group {
	        flex-direction: column;
	    }

    .btn-group .btn {
        border-radius: 12px !important;
        margin-bottom: 0.5rem;
    }

    /* 小画面で縦並びのボタン高さにログアウトが引っ張られないようにする */
    .topbar-actions {
        align-items: flex-start;
    }
}

/* Code and pre blocks */
code {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.875em;
    font-weight: 500;
}

pre {
    background: rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 1.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    overflow-x: auto;
}

/* Image styling */
img.img-fluid {
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease;
}

img.img-fluid:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

/* Utility classes */
.glass {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

/* ダークモードでもライト配色を維持して白背景の可読性を確保 */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: light;
        --light-color: #f8fafc;
        --dark-color: #1e293b;
    }
}

/* base layout でも管理画面と同等の視認性を付与 */
.admin-panel-chip {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    margin-top: 0.4rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #c2e9fb 0%, #a1c4fd 100%);
    color: #1a202c;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 10px rgba(161, 196, 253, 0.35);
}
