/* ===================================
   Voice KY Assistant - Main Styles
   =================================== */

:root {
    /* Colors */
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #4a90e8;
    --success: #34a853;
    --warning: #fbbc05;
    --danger: #ea4335;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* Safe Area */
    --safe-top: env(safe-area-inset-top, 0);
    --safe-bottom: env(safe-area-inset-bottom, 0);
}

/* ===================================
   Layout
   =================================== */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--space-md);
    padding-top: calc(var(--safe-top) + var(--space-md));
    padding-bottom: calc(var(--safe-bottom) + var(--space-md));
}

/* ===================================
   Loading
   =================================== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: var(--gray-600);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--space-md);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===================================
   Header
   =================================== */
.header {
    display: flex;
    align-items: center;
    padding: var(--space-md);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-title {
    font-size: 1.125rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.header-back {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* ===================================
   Buttons
   =================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all 0.2s ease;
    min-width: 120px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:active {
    background: var(--primary-dark);
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-800);
}

.btn-secondary:active {
    background: var(--gray-300);
}

.btn-large {
    width: 100%;
    padding: var(--space-lg);
    font-size: 1.25rem;
    border-radius: var(--radius-lg);
}

.btn-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    border-radius: var(--radius-full);
}

/* ===================================
   Home Screen
   =================================== */
.home {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-2xl);
}

.home-logo {
    font-size: 4rem;
    margin-bottom: var(--space-lg);
}

.home-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.home-subtitle {
    font-size: 1rem;
    color: var(--gray-600);
    margin-bottom: var(--space-2xl);
}

.home-start-btn {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.home-start-btn:active {
    transform: scale(0.95);
    box-shadow: var(--shadow-md);
}

.home-start-btn .icon {
    font-size: 3rem;
    margin-bottom: var(--space-sm);
}

.home-history-link {
    margin-top: var(--space-2xl);
    color: var(--primary);
    font-size: 1rem;
}

/* ===================================
   Chat Screen
   =================================== */

/* 会話開始バナー */
.start-conversation-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-radius: var(--radius-lg);
    margin: var(--space-md);
}

.btn-lg {
    padding: var(--space-md) var(--space-xl);
    font-size: 1.125rem;
    border-radius: var(--radius-full);
}

.chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--gray-50);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.message {
    max-width: 85%;
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-assistant {
    align-self: flex-start;
    background: white;
    border-bottom-left-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.message-user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.message-role {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-bottom: var(--space-xs);
}

.message-user .message-role {
    color: rgba(255, 255, 255, 0.7);
}

/* Chat Input Area */
.chat-input-area {
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: var(--space-md);
}

.chat-input-row {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.chat-text-input {
    flex: 1;
    padding: var(--space-md);
    background: var(--gray-100);
    border-radius: var(--radius-full);
    font-size: 1rem;
}

.chat-text-input:focus {
    background: white;
    box-shadow: 0 0 0 2px var(--primary);
}

.mic-btn {
    width: 60px;
    height: 60px;
    min-width: 60px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

.mic-btn:active,
.mic-btn.listening {
    background: var(--danger);
    transform: scale(1.1);
}

.mic-btn.listening {
    animation: pulse 1s ease infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(234, 67, 53, 0.4);
    }

    50% {
        box-shadow: 0 0 0 15px rgba(234, 67, 53, 0);
    }
}

.send-btn {
    background: var(--primary);
    color: white;
}

/* ===================================
   Confirm Screen
   =================================== */
.confirm {
    background: white;
}

.confirm-section {
    margin-bottom: var(--space-lg);
}

.confirm-section-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: var(--space-sm);
}

.confirm-section-content {
    padding: var(--space-md);
    background: var(--gray-50);
    border-radius: var(--radius-md);
}

.confirm-meta {
    display: flex;
    gap: var(--space-lg);
    color: var(--gray-600);
    font-size: 0.875rem;
    margin-bottom: var(--space-lg);
}

.confirm-hazard-item,
.confirm-counter-item {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--gray-200);
}

.confirm-hazard-item:last-child,
.confirm-counter-item:last-child {
    border-bottom: none;
}

.confirm-goal {
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
}

/* Advice Card */
.advice-card {
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cc 100%);
    border: 1px solid var(--warning);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
}

.advice-card-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
    color: #b5850a;
    margin-bottom: var(--space-sm);
}

.advice-item {
    padding: var(--space-sm) 0;
    font-size: 0.9375rem;
}

/* Confirm Actions */
.confirm-actions {
    display: flex;
    gap: var(--space-md);
    margin-top: auto;
    padding-top: var(--space-lg);
}

.confirm-actions .btn {
    flex: 1;
}

/* ===================================
   Done Screen
   =================================== */
.done {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-2xl);
}

.done-icon {
    font-size: 5rem;
    margin-bottom: var(--space-lg);
}

.done-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
    margin-bottom: var(--space-sm);
}

.done-message {
    color: var(--gray-600);
    margin-bottom: var(--space-2xl);
}

.done-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    width: 100%;
    max-width: 300px;
}

/* ===================================
   History Screen
   =================================== */
.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.history-item {
    display: flex;
    align-items: center;
    padding: var(--space-md);
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.history-item-icon {
    font-size: 1.5rem;
    margin-right: var(--space-md);
}

.history-item-content {
    flex: 1;
}

.history-item-date {
    font-weight: 600;
}

.history-item-summary {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-top: var(--space-xs);
}

.history-item-arrow {
    color: var(--gray-400);
}

.history-empty {
    text-align: center;
    color: var(--gray-500);
    padding: var(--space-2xl);
}

/* ===================================
   Toast / Notifications
   =================================== */
.toast {
    position: fixed;
    bottom: calc(var(--safe-bottom) + var(--space-lg));
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: white;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    z-index: 1000;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.toast.error {
    background: var(--danger);
}

.toast.success {
    background: var(--success);
}

/* ===================================
   Utility Classes
   =================================== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--gray-500);
}

.mb-sm {
    margin-bottom: var(--space-sm);
}

.mb-md {
    margin-bottom: var(--space-md);
}

.mb-lg {
    margin-bottom: var(--space-lg);
}