/*
 * == GENIUS-LEVEL UI ENGINEERING -- V7.0 (Definitive Version) ==
 *
 * Official Design Principles Analysis:
 * 1. Highlight Layer: `inset` shadows and pseudo-element highlights define glass contour and texture.
 * 2. Blur Layer: `backdrop-filter: blur()` is core for frosted glass and readability.
 * 3. Shadow Layer: `box-shadow` casts soft external shadows for depth and distance.
 * 4. Perspective/Reflection Layer: `perspective` and 3D `transform` build the convex lens shape;
 *    dynamic highlights simulate light refraction/reflection through curved surfaces.
*/

:root {
    --bg-color: #F4F1EC;
    --apple-ease: cubic-bezier(0.25, 0.1, 0.25, 1);
    --liquid-motion-curve: cubic-bezier(0.16, 1, 0.3, 1);
}

/* === GENIUS-LEVEL GLASS UI ANIMATION SYSTEM === */

/* Enhanced Glass Material Properties */
.glass-ui-container {
    /* width: auto; /* Adjusted by content */
    border-radius: var(--radius-lg); /* unified curvature */
    background: rgba(30, 30, 30, 0.25);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 16px;
    position: relative;
    z-index: 1;
    transform: rotateX(0deg) rotateY(0deg); /* Initial state for hover effect */
    transform-style: preserve-3d;
    transition: all 0.6s var(--apple-ease);
    box-shadow:
        inset 0px 2px 8px rgba(255, 255, 255, 0.07),
        inset -1px -2px 4px rgba(255, 255, 255, 0.04),
        0 40px 80px -20px rgba(0, 0, 0, 0.35);
    --glass-primary: rgba(255, 255, 255, 0.12);
    --glass-secondary: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.25);
    --glass-shadow: rgba(0, 0, 0, 0.15);
    --glass-glow: rgba(255, 255, 255, 0.4);
}

.glass-ui-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: inherit;

    opacity: 0.8;
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.6s var(--apple-ease), transform 0.6s var(--apple-ease);
}

.glass-ui-container:hover {
    transform: scale(1.05) rotateX(8deg) rotateY(-10deg);
    box-shadow:
        inset 0px 4px 15px rgba(255, 255, 255, 0.1),
        inset -2px -4px 8px rgba(255, 255, 255, 0.05),
        0 60px 100px -20px rgba(0, 0, 0, 0.4);
}

.glass-ui-container:hover::before {
    opacity: 1;
    transform: scale(1.05) translate(-5px, -5px);
}

/* Remove outer frame for mode select container */
.mode-select-container.glass-ui-container {
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    transform: none !important; /* Also disable 3D effect */
}

/* Specific padding for retry button container is already handled by its own rule below */

/* V12.0 Ultimate Purity Additions */
.glass-ui-container.clear-mode {
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    background: rgba(80, 80, 80, 0.15); /* Adjusted background for clear mode */
    /* Transition for backdrop-filter needs to be separate for some browsers */
    transition: all 0.6s var(--apple-ease), backdrop-filter 0.3s var(--apple-ease);
}

/* Frosted Glass Highlight Layer (original ::before) */
/* .glass-ui-container::before is already defined above */

/* Neutralized Highlight/Surface for Clear Glass */
.glass-ui-container::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 3; /* Above the frosted highlight */
    background: none; /* Pure, no artificial slash/gradient */
    opacity: 0;
    transition: opacity 0.5s var(--apple-ease);
}

.glass-ui-container.clear-mode::before {
    opacity: 0 !important; /* Hide frosted highlight in clear mode */
}

.glass-ui-container.clear-mode::after {
    opacity: 1 !important; /* Show the pure surface for clear mode (even if it's just 'none' background, it signifies the state) */
}

.buttons-row {
    display: flex;
    position: relative;
    padding: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transform: none !important;
    width: auto;
    min-width: 180px;
}

.pill-button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    padding: 10px 16px;
    color: rgba(255, 255, 255, 0.8);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    will-change: background, color;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center;
    outline: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

/* 移除过度的动画效果，保持简洁 */

.pill-button span {
    display: block;
}

.pill-button:hover {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.95);
}

.pill-button:hover::before {
    left: 100%;
}

.pill-button.active {
    background: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 1);
    font-weight: 600;
    box-shadow:
        0 2px 8px rgba(255, 255, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.pill-button.active:hover {
    background: rgba(255, 255, 255, 0.3);
    box-shadow:
        0 3px 12px rgba(255, 255, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Active State Indicator Enhancement */
.active-state-indicator {
    background: var(--unified-bg); /* 统一激活指示器背景 */
    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 1),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    transition: all 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

/* Precise Toggle Button Specialized Animation */
#precise-toggle-button {
    position: relative;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

#precise-toggle-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, var(--glass-glow) 0%, transparent 70%);
    border-radius: var(--radius-full);
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    pointer-events: none;
    z-index: -1;
}

#precise-toggle-button:hover::after {
    width: 120%;
    height: 120%;
    opacity: 0.3;
}

#precise-toggle-button.active {
    background: var(--unified-glass); /* 统一精细模式背景 */
    border-color: var(--accent);
    color: var(--unified-text);
    box-shadow:
        0 0 20px rgba(0, 123, 255, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

#precise-toggle-button.active::after {
    background: radial-gradient(circle, rgba(100, 200, 255, 0.4) 0%, transparent 70%);
    width: 100%;
    height: 100%;
    opacity: 0.5;
}

/* 简化的按钮交互 */
.pill-button:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .buttons-row {
        min-width: 160px;
        padding: 3px;
    }

    .pill-button {
        padding: 8px 12px;
        font-size: 13px;
    }

    .mode-label {
        font-size: 14px;
        margin-right: 12px;
    }
}

/* 移除过度动画效果 */

/* Glass Container Breathing Effect */
@keyframes glass-breathe {
    0%, 100% {
        box-shadow:
            inset 0px 2px 8px rgba(255, 255, 255, 0.07),
            inset -1px -2px 4px rgba(255, 255, 255, 0.04),
            0 40px 80px -20px rgba(0, 0, 0, 0.35);
    }
    50% {
        box-shadow:
            inset 0px 3px 12px rgba(255, 255, 255, 0.1),
            inset -1px -3px 6px rgba(255, 255, 255, 0.06),
            0 45px 90px -20px rgba(0, 0, 0, 0.4);
    }
}

.glass-ui-container.breathing {
    animation: glass-breathe 4s ease-in-out infinite;
}

/* Enhanced Focus States */
.pill-button:focus-visible {
    outline: 2px solid rgba(100, 200, 255, 0.5);
    outline-offset: 2px;
}

/* Remove outer frame for precise toggle container */
.precise-toggle-container.glass-ui-container {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}
.precise-toggle-container.glass-ui-container:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Remove outer frame for retry button container */
.retry-button-container.glass-ui-container {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.retry-button-container.glass-ui-container:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Retry button: same normal and hover as precise active pill-button */
.retry-button-container .pill-button.icon-button,
#retry-last-input-button {
    background: var(--glass-highlight);
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    color: #000;
    font-weight: 600;
    transform: scale(1.05);
    box-shadow:
        0 2px 15px rgba(255, 255, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}
.retry-button-container .pill-button.icon-button:hover,
#retry-last-input-button:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.08);
    box-shadow:
        0 4px 25px rgba(255, 255, 255, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        inset 0 -1px 0 rgba(0, 0, 0, 0.15);
}

.retry-button-container .pill-button.icon-button:active,
#retry-last-input-button:active {
    transform: scale(1.02); /* Pressed effect */
    box-shadow:
        0 1px 8px rgba(255, 255, 255, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

/* Mode label style - 简洁透明玻璃风格 */
.mode-label {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-right: 16px;
    letter-spacing: 0.5px;
    user-select: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: color 0.3s ease;
}

.mode-label:hover {
    color: rgba(255, 255, 255, 1);
}

.mode-select-container.glass-ui-container:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Enhanced Spin animation for retry button */
@keyframes retry-spin {
    0% { 
        transform: scale(1.05) rotate(0deg);
        box-shadow:
            0 2px 15px rgba(255, 255, 255, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.5),
            inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    }
    50% {
        transform: scale(1.1) rotate(180deg);
        box-shadow:
            0 4px 20px rgba(255, 255, 255, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.6),
            inset 0 -1px 0 rgba(0, 0, 0, 0.15);
    }
    100% { 
        transform: scale(1.05) rotate(360deg);
        box-shadow:
            0 2px 15px rgba(255, 255, 255, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.5),
            inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    }
}

.pill-button.icon-button.spin,
#retry-last-input-button.spin {
    animation: retry-spin 0.8s cubic-bezier(0.23, 1, 0.32, 1);
    transform-origin: center;
    pointer-events: none; /* Prevent multiple clicks during animation */
    transition: none !important;
}

.pill-button.icon-button.spin svg,
#retry-last-input-button.spin svg {
    filter: drop-shadow(0 2px 8px rgba(255, 255, 255, 0.4));
}

/* === Footer White Theme Override === */

/* === Mode Select Pill Group Rounded Ends === */
.mode-select-container .buttons-row {
  display: flex;
  overflow: hidden; /* clip inner corners */
  border-radius: var(--radius-lg);
}
.mode-select-container .pill-button {
  border-radius: 0; /* reset standard */
}
.mode-select-container .pill-button:first-child {
  border-top-left-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-lg);
}
.mode-select-container .pill-button:last-child {
  border-top-right-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.input-area .mode-label,
.input-area .pill-button,
.input-area .pill-button span,
.input-area .pill-button.icon-button,
.input-area .icon-button,
.input-area .icon-button svg {
  color: #ffffff !important;
  fill: #ffffff !important;
  stroke: #ffffff !important;
}

.input-area .icon-button svg {
  color: #ffffff !important;
  fill: none !important; /* keep transparent to show circular arrow */
  stroke: #ffffff !important;
}
