/* SandboxCafe レスポンシブデザイン・ユーティリティスタイル */

/* タブレット・スマートフォン対応 */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .sandbox-cafe-container {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    /* 基本レイアウト */
    .sandbox-cafe-container {
        padding: 1rem;
    }
    
    .sandbox-cafe-header {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .sandbox-cafe-header h1 {
        font-size: 2rem;
    }
    
    .sandbox-cafe-header .subtitle {
        font-size: 1rem;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .sandbox-section, .chat-section {
        padding: 1.5rem;
    }
    
    /* チャット機能 */
    .chat-tabs {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .chat-tab {
        flex: 1 1 calc(50% - 0.25rem);
        min-width: 120px;
        font-size: 0.8rem;
        padding: 0.6rem 0.8rem;
    }
    
    .chat-messages {
        height: 250px;
        font-size: 0.9rem;
    }
    
    .chat-input-area {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .chat-send-btn {
        width: 100%;
        padding: 1rem;
    }
    
    /* サンドボックス機能 */
    .sandbox-content {
        padding: 1rem;
    }
    
    .webapp-item-actions {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .webapp-item-actions .btn-small {
        width: 100%;
        text-align: center;
        padding: 0.8rem;
        font-size: 0.9rem;
    }
    
    .api-key-notice {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .notice-icon {
        font-size: 2rem;
    }
    
    /* URL管理 */
    .url-item-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .url-item-actions .btn-small {
        width: 100%;
        text-align: center;
    }
    
    .url-stats {
        text-align: left;
    }
    
    /* WEBアプリ統計 */
    .webapp-stats {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .stats-item {
        display: block;
        width: 100%;
    }
    
    /* フォーム要素 */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .webapp-form .form-input,
    .webapp-form .form-textarea {
        font-size: 0.9rem;
        padding: 0.8rem;
    }
    
    /* ボタン */
    .execute-btn {
        font-size: 1rem;
        padding: 0.8rem 1.5rem;
    }
    
    .prompt-btn {
        min-width: auto;
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 480px) {
    /* 超小画面対応 */
    .sandbox-cafe-container {
        padding: 0.5rem;
    }
    
    .sandbox-cafe-header {
        padding: 1rem;
    }
    
    .sandbox-cafe-header h1 {
        font-size: 1.8rem;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        text-align: left;
    }
    
    .section-header h2 {
        font-size: 1.3rem;
    }
    
    .chat-tab {
        flex: 1 1 100%;
        margin-bottom: 0.3rem;
    }
    
    .chat-messages {
        height: 200px;
        font-size: 0.8rem;
    }
    
    .webapp-item {
        padding: 0.8rem;
    }
    
    .webapp-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .url-item {
        padding: 0.8rem;
    }
    
    .url-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .login-prompt-content {
        padding: 1.5rem;
        margin: 0.5rem;
    }
    
    .login-prompt-content h2 {
        font-size: 1.5rem;
    }
    
    .login-prompt-buttons {
        gap: 0.5rem;
    }
    
    .prompt-btn {
        font-size: 1rem;
        padding: 0.8rem 1.5rem;
    }
}

/* ランドスケープタブレット */
@media (max-width: 1024px) and (orientation: landscape) {
    .main-content {
        grid-template-columns: 1fr 1fr;
    }
    
    .chat-messages {
        height: 250px;
    }
}

/* プリント用スタイル */
@media print {
    .sandbox-cafe-container {
        background: white !important;
        box-shadow: none !important;
    }
    
    .sandbox-cafe-header {
        background: #f8f9fa !important;
        color: #333 !important;
        box-shadow: none !important;
    }
    
    .chat-section {
        display: none;
    }
    
    .sandbox-section {
        page-break-inside: avoid;
    }
    
    .btn, button {
        display: none;
    }
    
    .code-editor {
        background: white !important;
        color: #333 !important;
        border: 1px solid #ccc !important;
    }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .sandbox-cafe-container {
        background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
        color: #e0e0e0;
    }
    
    .sandbox-section, .chat-section {
        background: #2d2d2d;
        border-color: #404040;
        color: #e0e0e0;
    }
    
    .form-input, .form-textarea, .parameter-input textarea, .api-selector select {
        background: #3d3d3d;
        border-color: #555;
        color: #e0e0e0;
    }
    
    .result-display {
        background: #2d2d2d;
        border-color: #555;
        color: #e0e0e0;
    }
    
    .chat-messages {
        background: #2d2d2d;
        border-color: #555;
    }
    
    .chat-message {
        background: #3d3d3d;
        border-left-color: #CD853F;
        color: #e0e0e0;
    }
}

/* アクセシビリティ対応 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .auth-loading-spinner {
        animation: none;
    }
}

/* 高コントラストモード */
@media (prefers-contrast: high) {
    .sandbox-cafe-header {
        border: 3px solid #000;
    }
    
    .section-header {
        border-bottom-color: #000;
        border-bottom-width: 3px;
    }
    
    .form-input:focus, .form-textarea:focus, .api-selector select:focus {
        border-color: #000 !important;
        box-shadow: 0 0 0 3px #000 !important;
    }
    
    .btn:focus, button:focus {
        outline: 3px solid #000;
        outline-offset: 2px;
    }
}

/* フォントサイズ調整対応 */
@media (min-resolution: 2dppx) {
    .code-editor, .code-highlight {
        font-size: 0.95rem !important;
    }
    
    .char-count {
        font-size: 0.85rem;
    }
}

/* ユーティリティクラス */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.d-none {
    display: none !important;
}

.d-block {
    display: block !important;
}

.d-flex {
    display: flex !important;
}

.justify-center {
    justify-content: center !important;
}

.align-center {
    align-items: center !important;
}

.gap-1 {
    gap: 0.5rem !important;
}

.gap-2 {
    gap: 1rem !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: 0.5rem !important;
}

.mb-2 {
    margin-bottom: 1rem !important;
}

.mt-0 {
    margin-top: 0 !important;
}

.mt-1 {
    margin-top: 0.5rem !important;
}

.mt-2 {
    margin-top: 1rem !important;
}