/* Apple風デザインシステム準拠 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    background: #F5F5F7;
    min-height: 100vh;
    color: #1D1D1F;
    line-height: 1.5;
}

.container {
    background: #FFFFFF;
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
}

h1 {
    color: #000000;
    text-align: center;
    margin-bottom: 32px;
    font-size: 34px;
    font-weight: 700;
    line-height: 1.2;
}

.subtitle {
    text-align: center;
    color: #666666;
    margin-bottom: 32px;
    font-size: 17px;
}

.control-section {
    margin-bottom: 32px;
    padding: 20px;
    background: #FFFFFF;
    border-radius: 16px;
    border: 1px solid #EEEEEE;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.control-section h2 {
    color: #000000;
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.3;
}

.button-group {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

button {
    padding: 12px 24px;
    font-size: 17px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    min-height: 44px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
}

.btn-primary {
    background: #007AFF;
    color: #FFFFFF;
}

.btn-primary:hover {
    background: #0056CC;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.btn-primary:disabled {
    background: #007AFF;
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: transparent;
    color: #007AFF;
    border: 1px solid #007AFF;
}

.btn-secondary:hover {
    background: #007AFF;
    color: #FFFFFF;
}

.btn-secondary:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-danger {
    background: #FF3B30;
    color: #FFFFFF;
}

.btn-danger:hover {
    background: #D70015;
}

.btn-danger:disabled {
    background: #FF3B30;
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-success {
    background: #4CD964;
    color: #FFFFFF;
}

.btn-success:hover {
    background: #32D74B;
}

.btn-success:disabled {
    background: #4CD964;
    opacity: 0.3;
    cursor: not-allowed;
}

.status {
    padding: 16px;
    margin: 16px 0;
    border-radius: 12px;
    font-weight: 500;
    font-size: 17px;
}

.status.connected {
    background: rgba(76, 217, 100, 0.15);
    color: #2D7D32;
    border: 1px solid rgba(76, 217, 100, 0.3);
}

.status.disconnected {
    background: rgba(255, 59, 48, 0.15);
    color: #C62828;
    border: 1px solid rgba(255, 59, 48, 0.3);
}

.status.scanning {
    background: rgba(255, 149, 0, 0.15);
    color: #E65100;
    border: 1px solid rgba(255, 149, 0, 0.3);
}

.device-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #EEEEEE;
    border-radius: 12px;
    margin: 16px 0;
    background: #FFFFFF;
}

.device-item {
    padding: 16px;
    border-bottom: 1px solid #EEEEEE;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.device-item:hover {
    background: #F5F5F7;
}

.device-item:last-child {
    border-bottom: none;
}

.device-name {
    font-weight: 600;
    color: #000000;
    margin-bottom: 4px;
    font-size: 17px;
}

.device-id {
    color: #666666;
    font-size: 14px;
    font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
}

.log-area {
    background: #1D1D1F;
    color: #F5F5F7;
    padding: 16px;
    border-radius: 12px;
    height: 200px;
    overflow-y: auto;
    font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
}

.input-group {
    display: flex;
    gap: 16px;
    margin: 16px 0;
    align-items: center;
}

.input-group label {
    min-width: 120px;
    font-weight: 500;
    color: #000000;
    font-size: 17px;
}

.input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #EEEEEE;
    border-radius: 8px;
    font-size: 17px;
    background: #FFFFFF;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
    transition: border-color 0.2s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

.characteristics-list {
    background: #FFFFFF;
    border: 1px solid #EEEEEE;
    border-radius: 16px;
    padding: 20px;
    margin: 16px 0;
}

.characteristic-item {
    padding: 16px;
    border-bottom: 1px solid #EEEEEE;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.characteristic-item:last-child {
    border-bottom: none;
}

.characteristic-uuid {
    font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
    font-size: 14px;
    color: #666666;
}

.characteristic-controls {
    display: flex;
    gap: 8px;
}

.characteristic-controls button {
    padding: 8px 16px;
    font-size: 14px;
    min-height: 32px;
    border-radius: 8px;
}

.data-display {
    background: #F5F5F7;
    padding: 16px;
    border-radius: 12px;
    margin: 16px 0;
    font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
    font-size: 14px;
    border: 1px solid #EEEEEE;
    color: #1D1D1F;
}

.error {
    background: rgba(255, 59, 48, 0.15);
    color: #C62828;
    border: 1px solid rgba(255, 59, 48, 0.3);
    padding: 16px;
    border-radius: 12px;
    margin: 16px 0;
    font-size: 17px;
}

/* トグルスイッチ */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 16px 0;
}

.toggle-group label {
    font-weight: 500;
    color: #000000;
    font-size: 17px;
}

.toggle-switch {
    position: relative;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #E5E5E7;
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .toggle-slider {
    background-color: #007AFF;
}

input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

/* リアルタイム表示エリア */
.realtime-display {
    background: #1D1D1F;
    color: #F5F5F7;
    padding: 16px;
    border-radius: 12px;
    height: 150px;
    overflow-y: auto;
    font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
    margin: 16px 0;
    border: 1px solid #333333;
}

.realtime-display.active {
    border-color: #007AFF;
    background: linear-gradient(135deg, #1D1D1F, #2D2D2F);
}

.realtime-data-item {
    padding: 8px 0;
    border-bottom: 1px solid #333333;
    animation: fadeIn 0.3s ease;
}

.realtime-data-item:last-child {
    border-bottom: none;
}

.realtime-timestamp {
    color: #8E8E93;
    font-size: 12px;
}

.realtime-hex {
    color: #FF9F0A;
    font-weight: 600;
    margin: 4px 0;
}

.realtime-text {
    color: #34C759;
    margin: 4px 0;
}

.realtime-bytes {
    color: #64D2FF;
    font-size: 12px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* リアルタイム表示の統計情報 */
.realtime-stats {
    background: #F5F5F7;
    padding: 12px;
    border-radius: 8px;
    margin: 16px 0;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 14px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-weight: 600;
    color: #007AFF;
    font-size: 18px;
}

.stat-label {
    color: #666666;
    font-size: 12px;
}

/* 設定グループ */
.setting-group {
    margin-bottom: 16px;
    padding: 12px;
    background: #F8F9FA;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
}

.setting-group label {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
}

.setting-group input[type="checkbox"] {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    accent-color: #007AFF;
}

/* レスポンシブデザイン */
@media (max-width: 767px) {
    body {
        padding: 16px;
    }

    .container {
        padding: 16px;
    }

    .control-section {
        padding: 16px;
    }

    .button-group {
        flex-direction: column;
        gap: 8px;
    }

    .input-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .input-group label {
        min-width: auto;
    }

    .characteristic-controls {
        flex-direction: column;
        gap: 4px;
    }

    h1 {
        font-size: 28px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    body {
        padding: 24px;
    }

    .container {
        padding: 20px;
    }
}

@media (min-width: 1024px) {
    body {
        padding: 32px;
    }

    .container {
        padding: 24px;
    }
}
