/* CSS Reset & Variables - Apple/Google Premium Tech Style */
:root {
    --bg-color: #f5f5f7;
    /* Apple-like off-white */
    --text-primary: #1d1d1f;
    /* SF Pro primary black */
    --text-secondary: #86868b;
    /* SF Pro secondary gray */
    --accent: #0071e3;
    /* Apple Blue */
    --accent-hover: #0077ed;
    --surface: rgba(255, 255, 255, 0.72);
    --surface-border: rgba(0, 0, 0, 0.08);
    /* Very subtle borders */
    --success: #34c759;
    --error: #ff3b30;
    --warning: #ff9500;
    --term-bg: #1c1c1e;
    /* Standard slate for terminal */
    --term-text: #f5f5f7;

    --blur-xl: blur(40px);
    --blur-md: blur(20px);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", system-ui, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    position: relative;
    letter-spacing: -0.01em;
}

/* Dynamic Background Blobs */
.background-elements {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.2;
}

.blob-1 {
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, #0071e3 0%, transparent 70%);
    top: -20%;
    left: -10%;
}

.blob-2 {
    width: 40vw;
    height: 40vw;
    background: radial-gradient(circle, #a371f7 0%, transparent 70%);
    bottom: -10%;
    right: -5%;
}

/* Main Layout */
.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1400px; /* Increased from 1200px to allow more space for the layout */
    padding: 60px 40px;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

header {
    text-align: center;
}

.logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 8px;
}

.logo-icon {
    font-size: 2.5rem;
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
}

main {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--surface);
    backdrop-filter: var(--blur-md);
    -webkit-backdrop-filter: var(--blur-md);
    border: 1px solid var(--surface-border);
    border-radius: 28px;
    padding: 32px;
    box-shadow: var(--shadow-md);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-panel:hover {
    box-shadow: var(--shadow-lg);
    border-color: rgba(0, 0, 0, 0.12);
}

/* Main Column */
.main-column {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Forms & Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--surface-border);
    color: var(--text-primary);
    padding: 16px 20px;
    border-radius: 16px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

input[type="text"]:focus {
    outline: none;
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    display: none;
}

.slider {
    position: relative;
    width: 48px;
    height: 28px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 34px;
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    border-radius: 50%;
    transition: .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

input:checked+.slider {
    background-color: var(--success);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input:checked~.toggle-label {
    color: var(--text-primary);
}

/* Button */
.btn-primary {
    background: var(--text-primary);
    color: #ffffff;
    border: none;
    padding: 14px 32px;
    border-radius: 18px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background: #000000;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #d2d2d7;
    color: #f5f5f7;
    box-shadow: none;
    cursor: not-allowed;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

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

/* Terminal Section */
.terminal-section {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.terminal-section.hidden {
    display: none;
}

.terminal-header {
    background: #1c1c1e;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.dots {
    display: flex;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.red {
    background-color: #ff5f56;
}

.dot.yellow {
    background-color: #ffbd2e;
}

.dot.green {
    background-color: #27c93f;
}

.terminal-title {
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    color: #98989d;
    letter-spacing: 0.02em;
}

.terminal-body {
    background: var(--term-bg);
    padding: 24px;
    height: 480px;
    overflow-y: auto;
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--term-text);
}

.log-line {
    margin-bottom: 6px;
}

.log-line.system {
    color: #86868b;
    font-style: italic;
}

.log-line.error {
    color: #ff453a;
}

.log-line.success {
    color: #32d74b;
}

.log-line.highlight {
    color: #0a84ff;
    font-weight: 600;
}

/* Sidebar - Premium History */
.sidebar-column {
    width: 380px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    position: sticky;
    top: 40px;
}

.history-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.history-header h3 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding-right: 8px;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.history-item {
    background: #ffffff;
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.2, 1, 0.2, 1);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
    background: #fff;
    border-color: rgba(0, 113, 227, 0.1);
}

.hi-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hi-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    font-weight: 400;
}

/* Modal - iOS Style */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #ffffff;
    width: 95%; /* Increased from 90% */
    max-width: 1400px; /* Increased from 960px to make preview wider and more fixed */
    height: 85vh;
    border-radius: 36px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transform: scale(0.9) translateY(40px);
    transition: all 0.5s cubic-bezier(0.32, 2, 0.55, 1);
}

.modal-overlay.show .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 30px 40px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.close-btn {
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    padding: 40px 60px;
    overflow-y: auto;
}

/* Markdown Content - Medium Clarity */
.markdown-content {
    color: #333333;
    font-size: 1.1rem;
    line-height: 1.7;
}

.markdown-content strong {
    font-weight: 700;
    color: #1d1d1f;
}

.markdown-content em {
    font-style: italic;
}

.markdown-content ul,
.markdown-content ol {
    margin-bottom: 20px;
    padding-left: 24px;
}

.markdown-content li {
    margin-bottom: 8px;
}

.markdown-content h3 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 16px;
}

.markdown-content hr {
    border: none;
    border-top: 1px solid #e5e5e7;
    margin: 32px 0;
}

.markdown-content h1 {
    font-size: 2.5rem;
    font-weight: 800;
    border-bottom: 2px solid #f2f2f7;
    padding-bottom: 16px;
    margin-bottom: 32px;
}

.markdown-content h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 40px;
    margin-bottom: 20px;
}

.markdown-content p {
    margin-bottom: 24px;
}

.markdown-content blockquote {
    background: #f2f2f7;
    border-left: 5px solid var(--accent);
    padding: 24px 30px;
    margin: 32px 0;
    border-radius: 0 20px 20px 0;
    font-style: italic;
    color: #48484a;
}

.markdown-content table {
    margin: 32px 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e5e5e7;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
}

.markdown-content pre {
    background: #f8f8f8;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0;
    font-size: 0.9rem;
}

.markdown-content pre code {
    white-space: pre;
    word-break: normal;
    word-wrap: normal;
}

.markdown-content th {
    background: #f2f2f7;
    color: #1d1d1f;
    padding: 16px;
}

.markdown-content td {
    padding: 16px;
    border-top: 1px solid #e5e5e7;
}

footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 24px;
    opacity: 0.6;
}

@media (max-width: 1000px) {
    main {
        flex-direction: column;
    }

    .sidebar-column {
        width: 100%;
        position: static;
        max-height: none;
    }

    .container {
        padding: 40px 20px;
    }

    h1 {
        font-size: 2.5rem;
    }
}

/* Specific Mobile Optimization for Modal and Markdown */
@media (max-width: 768px) {
    .container {
        padding: 30px 16px;
    }

    h1 {
        font-size: 2.2rem;
    }

    .modal-content {
        width: 96%;
        height: 92vh;
        border-radius: 28px;
    }

    .modal-header {
        padding: 20px 24px;
    }

    .modal-header h2 {
        font-size: 1.25rem;
    }

    .modal-body {
        padding: 20px;
    }

    .markdown-content {
        font-size: 1rem;
        line-height: 1.6;
    }

    .markdown-content h1 {
        font-size: 1.75rem;
        margin-bottom: 24px;
    }

    .markdown-content h2 {
        font-size: 1.4rem;
        margin-top: 30px;
    }

    .markdown-content blockquote {
        padding: 16px 20px;
        margin: 20px 0;
        border-radius: 0 12px 12px 0;
    }

    .markdown-content th,
    .markdown-content td {
        padding: 12px;
        font-size: 0.9rem;
    }
}
/* Feishu Config Collapsible */
.feishu-config.expanded .feishu-config-body {
    display: flex !important;
}
.feishu-config.expanded .feishu-arrow {
    transform: rotate(180deg);
}

/* Settings Config Collapsible (reuse feishu pattern) */
.settings-config.expanded .settings-config-body {
    display: flex !important;
}
.settings-config.expanded .settings-arrow {
    transform: rotate(180deg);
}

.settings-config-body textarea {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    line-height: 1.6;
}

.settings-config-body textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.settings-btn {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 8px 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.settings-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}

.settings-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.settings-btn.primary:hover {
    background: var(--accent-hover);
}

.settings-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}
