/* Apple-style Certificate Authentication System Styles */

:root {
    --apple-blue: #007AFF;
    --apple-blue-dark: #0A84FF;
    --apple-red: #FF3B30;
    --apple-red-dark: #FF453A;
    --apple-green: #34C759;
    --apple-green-dark: #30D158;
    --apple-gray: #8E8E93;
    --apple-gray2: #AEAEB2;
    --apple-gray3: #C7C7CC;
    --apple-gray4: #D1D1D6;
    --apple-gray5: #E5E5EA;
    --apple-gray6: #F2F2F7;

    /* System Colors - Light Mode */
    --system-background: #FFFFFF;
    --system-secondary-background: #F2F2F7;
    --system-tertiary-background: #FFFFFF;
    --system-grouped-background: #F2F2F7;
    --system-grouped-secondary-background: #FFFFFF;
    --system-text: #000000;
    --system-secondary-text: #3C3C43B3;
    --system-tertiary-text: #3C3C434D;
    --system-quaternary-text: #3C3C432E;
    --system-placeholder-text: #3C3C434D;
    --system-separator: #3C3C4349;
    --system-opaque-separator: #C6C6C8;
    --system-blue: #007AFF;
    --system-green: #34C759;
    --system-red: #FF3B30;
    --system-orange: #FF9500;
    --system-yellow: #FFCC00;
    --system-teal: #5AC8FA;
    --system-indigo: #5856D6;
    --system-purple: #AF52DE;
    --system-pink: #FF2D55;
    --system-gray: #8E8E93;
    --system-gray2: #AEAEB2;
    --system-gray3: #C7C7CC;
    --system-gray4: #D1D1D6;
    --system-gray5: #E5E5EA;
    --system-gray6: #F2F2F7;
}

/* Dark theme - both automatic and manual */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --system-background: #000000;
        --system-secondary-background: #1C1C1E;
        --system-tertiary-background: #2C2C2E;
        --system-grouped-background: #000000;
        --system-grouped-secondary-background: #1C1C1E;
        --system-text: #FFFFFF;
        --system-secondary-text: #EBEBF599;
        --system-tertiary-text: #EBEBF566;
        --system-quaternary-text: #EBEBF54D;
        --system-placeholder-text: #EBEBF566;
        --system-separator: #54545899;
        --system-opaque-separator: #38383A;
        --system-blue: #0A84FF;
        --system-green: #30D158;
        --system-red: #FF453A;
        --system-orange: #FF9F0A;
        --system-yellow: #FFD60A;
        --system-teal: #64D2FF;
        --system-indigo: #5E5CE6;
        --system-purple: #BF5AF2;
        --system-pink: #FF375F;
        --system-gray: #8E8E93;
        --system-gray2: #636366;
        --system-gray3: #48484A;
        --system-gray4: #3A3A3C;
        --system-gray5: #2C2C2E;
        --system-gray6: #1C1C1E;
    }
}

/* Manual dark theme override */
:root[data-theme="dark"] {
    --system-background: #0B0B0D;
    --system-secondary-background: #151518;
    --system-tertiary-background: #1E1E22;
    --system-grouped-background: #0B0B0D;
    --system-grouped-secondary-background: #151518;
    --system-text: #F5F5F7;
    --system-secondary-text: #D1D1D6;
    --system-tertiary-text: #9FA0A6;
    --system-quaternary-text: #7C7D83;
    --system-placeholder-text: #9FA0A6;
    --system-separator: #3A3A40;
    --system-opaque-separator: #2A2A2E;
    --system-blue: #0A84FF;
    --system-green: #30D158;
    --system-red: #FF453A;
    --system-orange: #FF9F0A;
    --system-yellow: #FFD60A;
    --system-teal: #64D2FF;
    --system-indigo: #5E5CE6;
    --system-purple: #BF5AF2;
    --system-pink: #FF375F;
    --system-gray: #8E8E93;
    --system-gray2: #636366;
    --system-gray3: #48484A;
    --system-gray4: #3A3A3C;
    --system-gray5: #2C2C2E;
    --system-gray6: #1C1C1E;
}

/* Improve contrast for key components in dark mode */
:root[data-theme="dark"] .apple-card,
:root[data-theme="dark"] .result-section,
:root[data-theme="dark"] .expandable-content {
    background: #151518;
    border: 1px solid #2A2A2E;
}

:root[data-theme="dark"] .apple-button-primary {
    background: #0A84FF;
    color: #FFFFFF;
}

:root[data-theme="dark"] .apple-input {
    background: #0F0F12;
    border-color: #2A2A2E;
    color: #F5F5F7;
}

:root[data-theme="dark"] .apple-input::placeholder {
    color: #9FA0A6;
}

:root[data-theme="dark"] .result-section li {
    background: #0F0F12;
    border-color: #2A2A2E;
}

:root[data-theme="dark"] .language-btn,
:root[data-theme="dark"] .theme-btn {
    background: #151518;
    border-color: #2A2A2E;
    color: #F5F5F7;
}

:root[data-theme="dark"] .udid-note {
    background: #FFD60A;
    color: #000;
}

:root[data-theme="dark"] .modal-content {
    background: #151518;
}

:root[data-theme="dark"] .error-toast {
    background: rgba(20, 20, 24, 0.95);
}

:root[data-theme="dark"] .network-indicator {
    background: #151518;
    border-color: #2A2A2E;
    color: #F5F5F7;
}

/* Manual light theme override */
:root[data-theme="light"] {
    --system-background: #FFFFFF;
    --system-secondary-background: #F2F2F7;
    --system-tertiary-background: #FFFFFF;
    --system-grouped-background: #F2F2F7;
    --system-grouped-secondary-background: #FFFFFF;
    --system-text: #000000;
    --system-secondary-text: #3C3C43B3;
    --system-tertiary-text: #3C3C434D;
    --system-quaternary-text: #3C3C432E;
    --system-placeholder-text: #3C3C434D;
    --system-separator: #3C3C4349;
    --system-opaque-separator: #C6C6C8;
    --system-blue: #007AFF;
    --system-green: #34C759;
    --system-red: #FF3B30;
    --system-orange: #FF9500;
    --system-yellow: #FFCC00;
    --system-teal: #5AC8FA;
    --system-indigo: #5856D6;
    --system-purple: #AF52DE;
    --system-pink: #FF2D55;
    --system-gray: #8E8E93;
    --system-gray2: #AEAEB2;
    --system-gray3: #C7C7CC;
    --system-gray4: #D1D1D6;
    --system-gray5: #E5E5EA;
    --system-gray6: #F2F2F7;
}

/* Prevent FOUC and initial flash */
body.preload { opacity: 0; }
body.preload * { visibility: hidden; }

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Icons", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--system-grouped-background);
    color: var(--system-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Language transition animations */
.language-transition {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.language-transition.fade-in {
    opacity: 1;
    transform: translateY(0);
}

/* Text elements that should animate during language change */
.title,
.mode-btn,
.apple-label,
.apple-button,
.apple-note p,
.udid-note,
.file-name {
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Layout */
.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 20px;
    height: calc(100% - env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(50px + env(safe-area-inset-bottom));
}

.title {
    text-align: center;
    font-size: 34px;
    font-weight: 700;
    margin: 30px 0;
    letter-spacing: -0.02em;
    color: var(--system-text);
}

/* Top Controls Container */
.top-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Theme Switcher */
.theme-switcher {
    display: flex;
    align-items: center;
}

.theme-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--system-gray5);
    background: var(--system-secondary-background);
    color: var(--system-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0) rotate(0deg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.theme-btn:hover {
    background: var(--system-gray6);
    transform: translateY(-1px) rotate(15deg);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.theme-btn:active {
    transform: translateY(0) rotate(0deg) scale(0.95);
    transition: all 0.1s ease;
}

.theme-icon {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
}

.theme-icon.light-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.theme-icon.dark-icon {
    opacity: 0;
    transform: rotate(180deg) scale(0.8);
}

/* Dark theme icon states */
[data-theme="dark"] .theme-icon.light-icon {
    opacity: 0;
    transform: rotate(-180deg) scale(0.8);
}

[data-theme="dark"] .theme-icon.dark-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Language Switcher */
.language-switcher {
    display: flex;
    gap: 8px;
}

.language-btn {
    background: var(--system-secondary-background);
    border: 1px solid var(--system-gray5);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--system-text);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.language-btn:hover {
    background: var(--system-gray6);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.language-btn.active {
    background: var(--system-blue);
    color: #FFFFFF;
    border-color: var(--system-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.language-btn.active:hover {
    background: var(--apple-blue-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 122, 255, 0.4);
}

/* Mode Switcher */
.mode-switcher {
    display: flex;
    background: var(--system-secondary-background);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.mode-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    color: var(--system-secondary-text);
    position: relative;
    z-index: 2;
    transform: scale(1);
}

.mode-btn:hover {
    color: var(--system-text);
    transform: scale(1.02);
}

.mode-btn.active {
    background: var(--system-blue);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
    transform: scale(1.02);
}

.mode-btn.active:hover {
    background: var(--apple-blue-dark);
    box-shadow: 0 3px 12px rgba(0, 122, 255, 0.4);
}


/* Mode panels transition (file-mode / udid-mode) */
.mode-panel {
    overflow: hidden;
    transition: opacity 0.25s ease, transform 0.25s ease, max-height 0.35s ease, padding 0.35s ease, margin 0.35s ease;
    will-change: opacity, transform, max-height;
}

/* Expanded/visible state */
.mode-panel.showing {
    opacity: 1;
    transform: translateY(0);
    max-height: 2000px; /* 足够大的值以容纳内容高度 */
}

/* Collapsed/hidden state (keep in flow for animation) */
.mode-panel.hiding {
    opacity: 0;
    transform: translateY(-8px);
    max-height: 0;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    pointer-events: none;
}

/* Cards */
.apple-card {
    background: var(--system-grouped-secondary-background);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

/* Form Elements */
.form-group {
    margin-bottom: 24px;
}

.apple-label {
    display: block;
    margin-bottom: 8px;
    color: var(--system-secondary-text);
    font-size: 15px;
    font-weight: 500;
}

.apple-file-input {
    position: relative;
    width: 100%;
}

.apple-file-input input[type="file"] {
    position: absolute;
    left: -9999px;
}

.apple-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    transform: translateY(0) scale(1);
    position: relative;
    overflow: hidden;
}

.apple-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.apple-button:hover::before {
    left: 100%;
}

.apple-button-secondary {
    background: var(--system-secondary-background);
    color: var(--system-text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.apple-button-secondary:hover {
    background: var(--system-gray6);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.apple-button-primary {
    background: var(--system-blue);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.apple-button-primary:hover {
    background: var(--apple-blue-dark);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.4);
}

.apple-button:active {
    transform: translateY(0) scale(0.98);
    transition: all 0.1s ease;
}

.file-name {
    margin-top: 8px;
    text-align: center;
    color: var(--system-secondary-text);
    font-size: 15px;
}

.apple-input-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 8px;
}

.apple-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--system-gray5);
    border-radius: 10px;
    font-size: 17px;
    color: var(--system-text);
    background: var(--system-background);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    appearance: none;
    transform: translateY(0);
}

.apple-input:hover {
    border-color: var(--system-gray3);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.apple-input:focus {
    outline: none;
    border-color: var(--system-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15), 0 4px 12px rgba(0, 122, 255, 0.1);
    transform: translateY(-2px);
}

.apple-icon {
    margin-right: 8px;
    display: inline-block;
    vertical-align: middle;
    color: currentColor;
}

/* Ensure icons visible in dark theme on secondary buttons */
:root[data-theme="dark"] .apple-button-secondary .apple-icon {
    color: #F5F5F7;
}

:root[data-theme="light"] .apple-button-secondary .apple-icon {
    color: var(--system-text);
}

/* Notes */
.apple-note {
    text-align: center;
    margin-top: 24px;
    padding: 16px;
    background: var(--system-secondary-background);
    border-radius: 14px;
}

.apple-note p {
    color: var(--system-tertiary-text);
    font-size: 15px;
}

/* UDID Mode Specific */
.udid-note {
    background: var(--system-yellow);
    color: #000;
    border-radius: 10px;
    padding: 12px 16px;
    margin-top: 16px;
    font-size: 14px;
    font-weight: 500;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    display: none;
    animation: modalFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.modal.closing {
    animation: modalFadeOut 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content {
    position: relative;
    background: var(--system-background);
    padding: 24px;
    border-radius: 16px;
    max-width: 1200px;
    margin: 20px auto;
    animation: modalSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    width: calc(100% - 40px);
    transform: translateY(0);
}

.modal.closing .modal-content {
    animation: modalSlideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-header {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--system-separator);
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 22px;
    font-weight: 700;
    color: var(--system-text);
}

.close {
    position: absolute;
    right: 24px;
    top: 24px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--system-secondary-text);
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--system-gray6);
}

/* Result Sections */
.result-section {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--system-secondary-background);
    border-radius: 14px;
}

.result-section h5 {
    font-size: 20px;
    font-weight: 600;
    color: var(--system-text);
    margin-bottom: 16px;
}

.result-section p {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--system-separator);
    font-size: 17px;
}

.result-section p:last-child {
    border-bottom: none;
}

.result-section strong {
    color: var(--system-secondary-text);
    font-weight: 500;
}

@media (min-width: 768px) {
    .cert-sections-wrapper {
        display: flex;
        gap: 20px;
        margin-bottom: 24px;
    }

    .cert-sections-wrapper .result-section {
        flex: 1;
        margin-bottom: 0;
    }

    .permissions-section {
        width: 100%;
    }
}

.result-section ul {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

@media (min-width: 768px) {
    .permissions-section ul {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

.result-section li {
    background: var(--system-background);
    border-radius: 10px;
    font-size: 15px;
    color: var(--system-text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border: 1px solid var(--system-gray5);
    height: 44px;
    white-space: nowrap;
    overflow: hidden;
}

.result-section li.allowed {
    border: 1px solid var(--system-green);
}

.result-section li.denied {
    border: 1px solid var(--system-red);
}

.result-section li .status {
    display: flex;
    align-items: center;
    font-weight: 500;
    flex-shrink: 0;
    min-width: 60px;
    justify-content: flex-end;
}

.result-section li > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
    flex: 1;
}

.result-section li .status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
}

.result-section li .status-indicator.allowed {
    background-color: var(--system-green);
}

.result-section li .status-indicator.denied {
    background-color: var(--system-red);
}

.result-section li .status-text {
    min-width: 44px;
    text-align: right;
}

.result-section li .status-text.allowed {
    color: var(--system-green);
}

.result-section li .status-text.denied {
    color: var(--system-red);
}

/* Toast and Loading */
.error-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    color: #FFFFFF;
    padding: 16px 24px;
    border-radius: 14px;
    z-index: 1001;
    display: none;
    text-align: center;
    max-width: 80%;
    font-size: 17px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: toastBounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s ease;
}

.error-toast:hover {
    transform: translate(-50%, -50%) scale(1.02);
}

.error-toast:active {
    transform: translate(-50%, -50%) scale(0.98);
}

.error-toast.hiding {
    animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.error-toast.swipe-out {
    animation: toastSwipeOut 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Network Status Indicator */
.network-status {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 999;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.network-status.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.network-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--system-secondary-background);
    border: 1px solid var(--system-gray5);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--system-text);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.network-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.network-status.connecting .network-indicator {
    border-color: var(--system-orange);
    color: var(--system-orange);
}

.network-status.error .network-indicator {
    border-color: var(--system-red);
    color: var(--system-red);
}

.network-status.success .network-indicator {
    border-color: var(--system-green);
    color: var(--system-green);
}

.network-status.connecting .network-icon svg {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #FFFFFF;
    animation: spin 0.8s linear infinite;
}

/* Animations */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    to {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
}

@keyframes modalSlideUp {
    0% {
        transform: translateY(100px) scale(0.9);
        opacity: 0;
    }
    50% {
        transform: translateY(-10px) scale(1.02);
        opacity: 0.8;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes modalSlideDown {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(10px) scale(0.98);
        opacity: 0.5;
    }
    100% {
        transform: translateY(50px) scale(0.9);
        opacity: 0;
    }
}

@keyframes toastSlideIn {
    0% {
        transform: translate(-50%, -80%) scale(0.7);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -45%) scale(1.05);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -45%) scale(0.95);
        opacity: 0.5;
    }
    100% {
        transform: translate(-50%, -30%) scale(0.7);
        opacity: 0;
    }
}

@keyframes toastBounceIn {
    0% {
        transform: translate(-50%, -100%) scale(0.3);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -40%) scale(1.1);
        opacity: 0.9;
    }
    70% {
        transform: translate(-50%, -55%) scale(0.95);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes toastSwipeOut {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(100%, -50%) scale(0.8);
        opacity: 0;
    }
}

/* Expandable Content */
.expandable-content {
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--system-secondary-background);
    border-radius: 10px;
    margin-top: 8px;
}

.expandable-content.expanded {
    max-height: 200px;
    padding: 16px;
}

.expand-trigger {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--system-secondary-background);
    border-radius: 10px;
    margin: 8px 0;
    font-size: 17px;
    font-weight: 500;
    color: var(--system-text);
}

.expand-trigger::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--system-secondary-text);
    border-bottom: 2px solid var(--system-secondary-text);
    transform: rotate(45deg);
    transition: transform 0.3s ease;
}

.expand-trigger.expanded::after {
    transform: rotate(-135deg);
}

/* Certificate List */
.cert-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px;
}

.cert-list li {
    padding: 16px;
    background: var(--system-background);
    border-radius: 10px;
    font-size: 15px;
    line-height: 1.4;
    color: var(--system-text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Status Styles */
.note {
    font-size: 13px;
    color: var(--system-tertiary-text);
    line-height: 1.3;
    margin-top: 8px;
}

[class^="result-section"] span.status-success {
    color: var(--system-green);
    font-weight: 500;
}

[class^="result-section"] span.status-error {
    color: var(--system-red);
    font-weight: 500;
}

/* Input Placeholders */
input[type="password"]::placeholder {
    color: var(--system-placeholder-text);
}

/* User Selection Prevention */
body, div, p, span, h1, h2, h3, h4, h5, h6, a, img {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

input, textarea {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

body {
    -webkit-touch-callout: none !important;
}

/* Mobile FAB Controls */
@media (max-width: 768px) {
    .top-controls { display: none; }

    .fab-container {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 1100;
    }

    .fab-btn {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--system-blue);
        color: #fff;
        border: none;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        cursor: pointer;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .fab-btn:active { transform: scale(0.96); }

    .fab-dot {
        display: block;
        width: 4px;
        height: 4px;
        background: #fff;
        border-radius: 50%;
        margin: 2px 0;
    }

    /* Circular FAB menu items vertically stacked */
    .fab-menu {
        position: absolute;
        bottom: 70px;
        right: 10px;
        background: transparent;
        border: none;
        border-radius: 12px;
        padding: 0;
        opacity: 0;
        transform: translateY(10px);
        pointer-events: none;
        transition: all 0.25s ease;
        min-width: 0;
    }

    .fab-menu.show {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    /* Hide animation (reverse) */
    .fab-menu.hiding .fab-group .theme-btn,
    .fab-menu.hiding .fab-group .language-btn { animation: fabHide 0.2s ease forwards; }

    @keyframes fabHide {
        0% { transform: translateY(0) scale(1); opacity: 1; }
        100% { transform: translateY(20px) scale(0.9); opacity: 0; }
    }

    .fab-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
        align-items: flex-end;
    }

    /* Round buttons */
    .fab-group .language-btn,
    .fab-group .theme-btn {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 8px 16px rgba(0,0,0,0.2);
        border: 1px solid var(--system-gray5);
        background: var(--system-secondary-background);
        color: var(--system-text);
        transform: translateY(20px) scale(0.9);
        opacity: 0;
    }

    /* Staggered animation */
    .fab-menu.show .fab-group .theme-btn {
        animation: fabPop 0.25s ease forwards;
        animation-delay: 0.05s;
    }

    .fab-menu.show .fab-group .language-btn:nth-child(1) { animation: fabPop 0.25s ease forwards; animation-delay: 0.10s; }
    .fab-menu.show .fab-group .language-btn:nth-child(2) { animation: fabPop 0.25s ease forwards; animation-delay: 0.15s; }
    .fab-menu.show .fab-group .language-btn:nth-child(3) { animation: fabPop 0.25s ease forwards; animation-delay: 0.20s; }

    @keyframes fabPop {
        0% { transform: translateY(20px) scale(0.9); opacity: 0; }
        100% { transform: translateY(0) scale(1); opacity: 1; }
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .container {
        padding: 16px;
    }

    .title {
        font-size: 28px;
        margin: 24px 0;
    }

    .apple-card {
        padding: 20px;
    }

    .apple-label {
        font-size: 15px;
    }

    .apple-input {
        padding: 12px 14px;
        font-size: 16px;
    }

    .apple-file-input input[type="file"],
    .apple-button {
        font-size: 16px;
        padding: 12px;
    }

    .result-section {
        padding: 16px;
    }

    .result-section h5 {
        font-size: 18px;
    }

    .result-section p,
    .result-section li {
        font-size: 14px;
    }

    .result-section ul {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .result-section li {
        padding: 10px 12px;
        height: 40px;
    }

    .result-section li .status {
        min-width: 52px;
    }

    .result-section li .status-text {
        min-width: 36px;
    }

    .modal-content {
        width: calc(100% - 32px);
        padding: 20px;
    }

    .language-switcher {
        top: 10px;
        right: 10px;
    }

    .language-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Hidden elements */
.hidden {
    display: none !important;
}
