/* ===========================
   UI究極強化パッチ
   =========================== */

/* ★ RSAパラメータ入力フィールド修正 — 線→ちゃんとした入力欄 */
.param-value {
    min-height: 2.8rem !important;
    padding: 0.6rem 0.8rem !important;
    font-size: 0.85rem !important;
    line-height: 1.5 !important;
    word-break: break-all;
    overflow-wrap: anywhere;
    background: rgba(0, 0, 0, 0.35) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 8px !important;
    transition: all 0.3s ease;
}

.param-value:hover {
    border-color: rgba(6, 182, 212, 0.3) !important;
    background: rgba(0, 0, 0, 0.45) !important;
}

/* ★ パラメータカード強化 */
.param-card {
    padding: 1rem 1.2rem !important;
    border-radius: 14px !important;
    background: rgba(17, 24, 39, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.param-card:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3) !important;
    border-color: rgba(6, 182, 212, 0.2) !important;
}

.param-symbol {
    font-size: 1.6rem !important;
    font-weight: 800 !important;
    margin-bottom: 0.3rem !important;
}

.param-name {
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem !important;
}

.param-desc {
    font-size: 0.7rem !important;
    color: #8b9cb8 !important;
    margin-top: 0.4rem !important;
}

/* ★ パラメータグリッド */
.param-grid {
    gap: 12px !important;
}

/* ★ フォーム入力フィールド全般強化 */
.form-select,
.form-input,
.form-textarea {
    padding: 0.75rem 1rem !important;
    font-size: 0.95rem !important;
    background: rgba(0, 0, 0, 0.35) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 12px !important;
    color: #f1f5f9 !important;
    transition: all 0.3s ease;
}

.form-select:focus,
.form-input:focus,
.form-textarea:focus {
    border-color: #06b6d4 !important;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15), 0 0 20px rgba(6, 182, 212, 0.1) !important;
    background: rgba(0, 0, 0, 0.5) !important;
}

.form-textarea {
    min-height: 100px !important;
    line-height: 1.7 !important;
}

/* ★ カード全般のプレミアム化 */
.card {
    background: rgba(17, 24, 39, 0.65) !important;
    border: 1px solid rgba(255, 255, 255, 0.07) !important;
    border-radius: 18px !important;
    backdrop-filter: blur(16px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12) !important;
}

.card-header {
    padding: 1.2rem 1.4rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.card-header h3 {
    font-size: 1rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.01em;
}

.card-header p {
    font-size: 0.8rem !important;
    color: #94a3b8 !important;
    margin-top: 0.2rem;
}

/* ★ ボタンの強化 */
.btn {
    padding: 0.65rem 1.3rem !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
    font-size: 0.88rem !important;
    letter-spacing: 0.02em;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn:hover::after {
    opacity: 1;
}

.btn:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3) !important;
}

.btn:active {
    transform: translateY(0) scale(0.98) !important;
}

.btn-primary {
    background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%) !important;
    border: none !important;
    color: #fff !important;
}

.btn-encrypt {
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%) !important;
    border: none !important;
    color: #fff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-decrypt {
    background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%) !important;
    border: none !important;
    color: #fff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ★ ビットプリセットボタン */
.bit-preset {
    padding: 0.4rem 0.8rem !important;
    border-radius: 8px !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #94a3b8 !important;
    transition: all 0.2s ease !important;
}

.bit-preset:hover,
.bit-preset.active {
    background: rgba(6, 182, 212, 0.15) !important;
    border-color: rgba(6, 182, 212, 0.4) !important;
    color: #06b6d4 !important;
}

/* ★ サイドバー強化 */
.sidebar {
    background: rgba(8, 12, 24, 0.95) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.06) !important;
    backdrop-filter: blur(20px) !important;
}

.sidebar-header {
    padding: 1.2rem 1.4rem !important;
}

.sidebar-header .logo-text {
    font-size: 1.3rem !important;
    font-weight: 800 !important;
    background: linear-gradient(135deg, #06b6d4, #a855f7) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

.nav-btn {
    padding: 0.65rem 1rem !important;
    border-radius: 10px !important;
    margin: 2px 8px !important;
    font-size: 0.82rem !important;
    transition: all 0.2s ease !important;
    border: 1px solid transparent !important;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

.nav-btn.active {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(168, 85, 247, 0.1)) !important;
    border-color: rgba(6, 182, 212, 0.3) !important;
    color: #06b6d4 !important;
}

.nav-icon {
    font-size: 1.1rem !important;
    min-width: 28px !important;
}

.nav-badge {
    font-size: 0.65rem !important;
    padding: 0.15rem 0.5rem !important;
    border-radius: 6px !important;
    background: rgba(255, 255, 255, 0.08) !important;
    font-weight: 600 !important;
}

.nav-section-label {
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.08em !important;
    padding: 0.8rem 1.2rem 0.4rem !important;
    color: #64748b !important;
}

/* ★ アコーディオン改善 */
.nav-accordion-toggle {
    padding: 0.6rem 1rem !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    border-radius: 10px !important;
    margin: 2px 8px !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    transition: all 0.2s ease !important;
}

.nav-accordion-toggle:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* ★ パネルヘッダー */
.panel-header {
    margin-bottom: 1.5rem !important;
}

.panel-title {
    font-size: 1.6rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em !important;
    background: linear-gradient(135deg, #f1f5f9, #94a3b8) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

.panel-icon {
    font-size: 1.8rem !important;
    margin-right: 0.5rem !important;
}

.panel-desc {
    font-size: 0.9rem !important;
    color: #94a3b8 !important;
    margin-top: 0.4rem !important;
    line-height: 1.6 !important;
}

/* ★ ステータスメッセージ */
.status {
    padding: 0.7rem 1rem !important;
    border-radius: 10px !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
}

.status.success {
    background: rgba(16, 185, 129, 0.1) !important;
    border: 1px solid rgba(16, 185, 129, 0.2) !important;
    color: #10b981 !important;
}

.status.error {
    background: rgba(244, 63, 94, 0.1) !important;
    border: 1px solid rgba(244, 63, 94, 0.2) !important;
    color: #f43f5e !important;
}

.status.info {
    background: rgba(6, 182, 212, 0.1) !important;
    border: 1px solid rgba(6, 182, 212, 0.2) !important;
    color: #06b6d4 !important;
}

/* ★ テーブル強化 */
.crypto-table {
    border-radius: 12px !important;
    overflow: hidden;
}

.crypto-table th {
    background: rgba(6, 182, 212, 0.08) !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    padding: 0.7rem 1rem !important;
    color: #94a3b8 !important;
}

.crypto-table td {
    padding: 0.6rem 1rem !important;
    font-size: 0.82rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
}

.crypto-table tr:hover td {
    background: rgba(255, 255, 255, 0.03) !important;
}

/* ★ スクロールバー美化 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ★ モバイルメニューボタン改善 */
.mobile-menu-btn {
    width: 44px !important;
    height: 44px !important;
    border-radius: 12px !important;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(168, 85, 247, 0.2)) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
    font-size: 1.2rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    backdrop-filter: blur(10px) !important;
    z-index: 1001 !important;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.35), rgba(168, 85, 247, 0.35)) !important;
    transform: scale(1.05);
}

/* ★ プログレスバー */
.progress-bar {
    height: 4px !important;
    border-radius: 2px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #06b6d4, #a855f7) !important;
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ★ スピナー */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ★ ツールチップ */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.4rem 0.8rem;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    font-size: 0.75rem;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 4px;
    pointer-events: none;
}

/* ★ 入力フォーカス時のラベルエフェクト */
.form-group:focus-within .form-label {
    color: #06b6d4 !important;
}

/* ★ コード表示 */
code,
pre {
    font-family: 'JetBrains Mono', 'Fira Code', monospace !important;
    font-size: 0.82rem !important;
}

pre {
    background: rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 12px !important;
    padding: 1rem !important;
    overflow-x: auto;
}

/* ★ 選択テキストのスタイル */
::selection {
    background: rgba(6, 182, 212, 0.3);
    color: #fff;
}

/* ★ レスポンシブ改善 */
@media (max-width: 768px) {
    .param-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .panel-title {
        font-size: 1.3rem !important;
    }

    .card-header {
        padding: 1rem !important;
    }

    .btn {
        padding: 0.7rem 1rem !important;
        font-size: 0.85rem !important;
        width: 100%;
    }

    .form-row {
        flex-direction: column !important;
    }

    .form-actions-vertical {
        flex-direction: row !important;
        gap: 8px !important;
        padding: 0.5rem 0 !important;
    }

    /* ステルス通信 — スマホ最適化 */
    #cipher-stealth .card-header,
    #cipher-e2e .card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    #cipher-stealth table {
        font-size: 0.65rem !important;
    }

    #cipher-stealth table th,
    #cipher-stealth table td {
        padding: 3px 2px !important;
    }

    /* スライダー — タッチ対応 */
    input[type="range"] {
        height: 32px !important;
        -webkit-appearance: none;
        appearance: none;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }

    /* 接続カード — モバイル */
    #stealthRoomInput {
        font-size: 0.95rem !important;
    }

    #btnStealthConnect {
        font-size: 0.95rem !important;
        padding: 12px !important;
    }

    /* エビデンスバッジ — モバイル */
    .evidence-badge {
        font-size: 0.65rem !important;
        padding: 2px 6px !important;
    }
}

@media (max-width: 480px) {
    .panel-title {
        font-size: 1.1rem !important;
    }

    .param-symbol {
        font-size: 1.3rem !important;
    }

    .card {
        border-radius: 14px !important;
    }

    /* ステルス通信 — 超小画面 */
    #cipher-stealth details summary {
        font-size: 0.75rem !important;
    }

    #stealthSecLevelBadge,
    #e2eSecLevelBadge {
        font-size: 1rem !important;
        min-width: 60px !important;
    }

    #cipher-stealth table {
        font-size: 0.6rem !important;
    }

    /* チャットエリア — モバイル */
    #stealthChat {
        min-height: 200px !important;
        max-height: 280px !important;
    }

    #stealthMsg {
        font-size: 0.9rem !important;
    }
}

/* ★ タッチデバイス用ホバー無効化 */
@media (hover: none) {
    .btn:hover {
        transform: none !important;
    }

    .card:hover {
        border-color: rgba(255, 255, 255, 0.07) !important;
    }

    .param-card:hover {
        transform: none !important;
    }
}

/* ★ PWA安全領域対応 */
@supports (padding: env(safe-area-inset-bottom)) {
    .sidebar {
        padding-bottom: env(safe-area-inset-bottom) !important;
    }

    #stealthChat {
        padding-bottom: calc(15px + env(safe-area-inset-bottom)) !important;
    }
}