/* IOC SC-DIXAE Formatter - Compact pibiCo styling */

/* ── Global compact overrides ── */
body {
    line-height: 1;
}

.app-header {
    height: 36px;
    padding: 0 0.75rem;
}

.app-header-title {
    font-size: 0.9rem;
    gap: 0.4rem;
}

.app-header-title svg {
    width: 18px;
    height: 18px;
}

.app-header-actions {
    gap: 0.4rem;
}

.app-header-btn {
    width: 28px;
    height: 28px;
}

.app-header-btn svg {
    width: 16px;
    height: 16px;
}

.app-header-link {
    padding: 5px 6px;
    font-size: 0.75rem;
    gap: 0.25rem;
    line-height: 1;
}

.app-header-link svg {
    width: 14px;
    height: 14px;
}

.app-main {
    padding: 0.4rem;
}

.app-footer {
    height: 28px;
    padding: 0 0.75rem;
    font-size: 0.65rem;
    gap: 0.4rem;
}

/* Override pibico-input for compact */
.pibico-input {
    padding: 5px 6px;
    font-size: 0.8rem;
    line-height: 1;
    border-radius: 5px;
}

/* Override pibico-btn for compact */
.pibico-btn {
    padding: 5px 8px;
    font-size: 0.8rem;
    line-height: 1;
    border-radius: 5px;
    gap: 0.3rem;
}

.pibico-btn svg {
    width: 14px;
    height: 14px;
}

.pibico-btn-icon {
    padding: 5px;
    color: white;
    border-color: rgba(255, 255, 255, 0.4);
}

.pibico-btn-icon:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: white;
}

/* ── Container ── */
.ioc-container {
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
    padding: 0.25rem;
}

/* ── Mode Tabs ── */
.mode-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 0.4rem;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 2px;
}

.mode-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 5px 6px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--text-light);
    font-weight: 600;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.mode-tab svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mode-tab:hover {
    background: rgba(70, 130, 180, 0.08);
    color: var(--primary-color);
}

.mode-tab.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 1px 4px rgba(70, 130, 180, 0.3);
}

/* ── Mode Panels ── */
.mode-panel {
    display: none;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 8px 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.mode-panel.active {
    display: block;
}

/* ── Form Groups ── */
.form-group {
    margin-bottom: 8px;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.7rem;
    line-height: 1;
    color: var(--accent-color);
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-hint {
    font-size: 0.7rem;
    line-height: 1;
    color: var(--text-light);
    margin-top: 3px;
}

.ioc-textarea {
    resize: vertical;
    min-height: 60px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.75rem;
    line-height: 1.15;
}

/* ── Attribute Rows ── */
.attr-row {
    display: flex;
    gap: 3px;
    margin-bottom: 3px;
    align-items: center;
}

.attr-type {
    width: 120px;
    min-width: 120px;
    padding: 5px 4px;
    border: 1px solid var(--glass-border);
    border-radius: 5px;
    font-size: 0.75rem;
    line-height: 1;
    font-family: 'Courier New', Courier, monospace;
    background: white;
    color: var(--text-color);
}

.attr-type:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(70, 130, 180, 0.1);
}

.attr-value {
    flex: 2;
}

.attr-comment {
    flex: 1;
}

.btn-remove-attr {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-light);
}

.btn-remove-attr svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn-remove-attr:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.btn-add-attr {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 5px 6px;
    border: 1px dashed var(--glass-border);
    border-radius: 5px;
    background: transparent;
    color: var(--primary-color);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    width: 100%;
    justify-content: center;
}

.btn-add-attr svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn-add-attr:hover {
    border-color: var(--primary-color);
    background: rgba(70, 130, 180, 0.05);
}

/* ── Generate Button — Red Brick ── */
#btnGenerate {
    background: linear-gradient(135deg, #b91c1c 0%, #991b1b 50%, #7f1d1d 100%);
    border: 1px solid #7f1d1d;
    color: white;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 6px rgba(185, 28, 28, 0.3);
}

#btnGenerate:hover:not(:disabled) {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 50%, #991b1b 100%);
    box-shadow: 0 3px 10px rgba(185, 28, 28, 0.4);
    transform: translateY(-1px);
}

#btnGenerate:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(185, 28, 28, 0.3);
}

#btnGenerate:disabled {
    background: #9ca3af;
    border-color: #9ca3af;
    box-shadow: none;
}

/* ── Form Actions ── */
.form-actions {
    display: flex;
    gap: 3px;
    margin-top: 8px;
    margin-bottom: 8px;
}

/* ── Output Section ── */
.output-section {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 8px 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 6px;
}

.output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3px;
}

.output-meta {
    font-size: 0.65rem;
    line-height: 1;
    color: var(--text-light);
}

.output-message {
    background: #1e293b;
    color: #e2e8f0;
    padding: 8px 8px;
    border-radius: 5px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.75rem;
    line-height: 1.15;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 4px;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid transparent;
    resize: vertical;
    min-height: 80px;
    outline: none;
}
.output-message:focus {
    border-color: var(--primary, #4682b4);
}

.btn-copy {
    width: 100%;
    justify-content: center;
}

/* ── Validate Section ── */
.validate-section {
    margin-top: 4px;
}

.validate-details {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    overflow: hidden;
}

.validate-details summary {
    padding: 5px 8px;
    cursor: pointer;
    user-select: none;
    font-size: 0.7rem;
    line-height: 1;
}

.validate-details summary:hover {
    background: rgba(70, 130, 180, 0.05);
}

.validate-body {
    padding: 0 8px 8px;
}

.validate-result {
    margin-top: 5px;
    padding: 5px 6px;
    border-radius: 5px;
    font-size: 0.75rem;
    line-height: 1.15;
}

.validate-result.valid {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #065f46;
}

.validate-result.invalid {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #991b1b;
}

.validate-result ul {
    margin: 3px 0 0 1rem;
    padding: 0;
}

.validate-result li {
    margin-bottom: 1px;
}

/* ── Email Upload Zone ── */
.email-upload-zone {
    border: 2px dashed var(--glass-border);
    border-radius: 6px;
    padding: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.email-upload-zone:hover,
.email-upload-zone.dragover {
    border-color: var(--primary-color);
    background: rgba(70, 130, 180, 0.05);
}

.email-upload-zone.has-file {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.upload-icon {
    margin-bottom: 2px;
}

.upload-icon svg {
    width: 22px;
    height: 22px;
    stroke: var(--primary-color);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.upload-text {
    font-size: 0.75rem;
    line-height: 1;
    color: var(--text-light);
}

.upload-filename {
    margin-top: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    color: #10b981;
}

.email-divider {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 6px 0;
    color: var(--text-light);
    font-size: 0.7rem;
    line-height: 1;
}

.email-divider::before,
.email-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--glass-border);
}

/* ── Settings Slide Panel ── */
.slide-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.slide-panel-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.slide-panel {
    position: fixed;
    top: 0;
    right: -45%;
    width: 45%;
    max-width: 360px;
    height: 100vh;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
    z-index: 201;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.slide-panel.active {
    right: 0;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 8px;
    border-bottom: 1px solid var(--glass-border);
}

.panel-header h3 {
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    color: var(--accent-color);
}

.panel-close {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.panel-close svg {
    width: 14px;
    height: 14px;
    stroke: var(--text-color);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.panel-close:hover {
    background: rgba(239, 68, 68, 0.1);
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    position: relative;
}

.panel-section {
    margin-bottom: 8px;
}

.section-title {
    font-weight: 600;
    font-size: 0.7rem;
    line-height: 1;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.panel-body p {
    line-height: 1.15;
}

.auth-input-group {
    display: flex;
    gap: 3px;
}

.auth-input-group .pibico-input {
    flex: 1;
}

.auth-status {
    font-size: 0.65rem;
    line-height: 1;
    margin-top: 3px;
}

.auth-status.connected {
    color: #10b981;
}

.auth-status.error {
    color: #ef4444;
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: center;
}

.toast {
    background: #1e293b;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.75rem;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}

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

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

/* ── Language Switcher ── */
.lang-switch {
    display: flex;
    gap: 1px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.lang-btn {
    padding: 4px 6px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.lang-btn.active {
    background: var(--primary-color);
    color: white;
}

.lang-btn:hover:not(.active) {
    background: rgba(70, 130, 180, 0.15);
}

/* ── Help Panel ── */
.help-panel {
    width: 50%;
    max-width: 480px;
    right: -50%;
}

.help-panel.active {
    right: 0;
}

.help-body {
    padding: 6px 10px;
}

.help-body p {
    font-size: 0.72rem;
    line-height: 1.2;
    color: var(--text-color);
    margin-bottom: 4px;
}

.help-section {
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

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

.help-heading {
    font-weight: 700;
    font-size: 0.75rem;
    line-height: 1;
    color: var(--accent-color);
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.help-subheading {
    font-weight: 700;
    font-size: 0.72rem;
    line-height: 1;
    color: var(--primary-color);
    margin-bottom: 3px;
}

.help-code {
    background: #1e293b;
    color: #e2e8f0;
    padding: 5px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.68rem;
    line-height: 1.25;
    margin: 3px 0;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.help-code code {
    display: block;
    font-family: inherit;
    font-size: inherit;
}

.help-small {
    font-size: 0.65rem;
    color: var(--text-light);
    line-height: 1.15;
    margin: 2px 0;
}

.help-example-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-light);
    margin-top: 3px;
    line-height: 1;
}

.help-list {
    margin: 2px 0 0 1rem;
    padding: 0;
    font-size: 0.72rem;
    line-height: 1.3;
}

.help-list li {
    margin-bottom: 1px;
}

.help-list code {
    background: rgba(70, 130, 180, 0.1);
    padding: 0 3px;
    border-radius: 2px;
    font-size: 0.68rem;
    font-family: 'Courier New', Courier, monospace;
}

.help-list-warn li {
    color: #991b1b;
}

/* ── History Panel ── */
.history-mode-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 6px;
    background: rgba(70, 130, 180, 0.06);
    border-radius: 5px;
    padding: 2px;
}

.history-mode-tab {
    flex: 1;
    padding: 5px 4px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-light);
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-align: center;
}

.history-mode-tab:hover {
    background: rgba(70, 130, 180, 0.1);
    color: var(--primary-color);
}

.history-mode-tab.active {
    background: var(--primary-color);
    color: white;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.history-empty {
    text-align: center;
    color: var(--text-light);
    font-size: 0.72rem;
    padding: 16px 0;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding: 5px 6px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    transition: background 0.15s;
}

.history-item:hover {
    background: rgba(70, 130, 180, 0.06);
}

.history-item-header {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.history-title {
    font-size: 0.72rem;
    line-height: 1;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.history-time {
    font-size: 0.6rem;
    line-height: 1;
    color: var(--text-light);
    white-space: nowrap;
    flex-shrink: 0;
}

.history-item-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.history-load-btn,
.history-delete-btn {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-light);
}

.history-load-btn svg,
.history-delete-btn svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.history-load-btn:hover {
    background: rgba(70, 130, 180, 0.1);
    color: var(--primary-color);
}

.history-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.history-delete-btn.confirm {
    background: #ef4444;
    color: white;
    animation: pulse-delete 0.3s ease;
}

@keyframes pulse-delete {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.mode-badge {
    display: inline-block;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mode-ioc {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}

.mode-sms {
    background: rgba(245, 158, 11, 0.12);
    color: #92400e;
}

.mode-email {
    background: rgba(59, 130, 246, 0.12);
    color: #1d4ed8;
}

.mode-file {
    background: rgba(16, 185, 129, 0.12);
    color: #065f46;
}

.history-load-more {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
    font-size: 0.72rem;
}

/* ── History Preview Overlay ── */
.history-preview {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10;
    display: flex;
    flex-direction: column;
    padding: 8px 8px;
}

.history-preview-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--glass-border);
}

.history-preview-title {
    flex: 1;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-preview-message {
    flex: 1;
    background: #1e293b;
    color: #e2e8f0;
    padding: 8px 8px;
    border-radius: 5px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.72rem;
    line-height: 1.2;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 6px;
}

.history-preview-actions {
    display: flex;
    gap: 3px;
}

.history-preview-actions .pibico-btn {
    flex: 1;
    justify-content: center;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .ioc-container {
        padding: 2px;
    }

    .mode-tab {
        font-size: 0.65rem;
        padding: 5px;
        gap: 2px;
    }

    .mode-tab svg {
        width: 11px;
        height: 11px;
    }

    .attr-row {
        flex-wrap: wrap;
    }

    .attr-type {
        width: 100%;
        min-width: unset;
    }

    .attr-value,
    .attr-comment {
        flex: 1 1 45%;
    }

    .slide-panel {
        width: 85%;
        max-width: none;
        right: -85%;
    }

    .help-panel {
        width: 90%;
        max-width: none;
        right: -90%;
    }
}
