/* ============================================
   Permission Policy Builder — Styles
   Theme: Dark Ocean Blue
   Primary: #3498DB, BG: #0A1628
   ============================================ */

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

    --bg: #0A1628;
    --bg-card: #0F2038;
    --bg-input: #0A1628;
    --bg-hover: #152C4A;

    --border: rgba(52, 152, 219, 0.15);
    --border-hover: rgba(52, 152, 219, 0.3);
    --border-focus: #3498DB;

    --text: #E8EFF5;
    --text-secondary: #8FA8C8;
    --text-muted: #4A6A8A;

    --primary: #3498DB;
    --primary-glow: rgba(52, 152, 219, 0.2);
    --secondary: #2980B9;
    --green: #2ECC71;
    --green-dim: rgba(46, 204, 113, 0.12);
    --red: #E74C3C;
    --red-dim: rgba(231, 76, 60, 0.12);
    --yellow: #F39C12;
    --yellow-dim: rgba(243, 156, 18, 0.12);

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.app {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px 40px;
}

.header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.header-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 0 20px var(--primary-glow);
}

.header-title {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-sub {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
    animation: fadeIn 0.35s ease-out;
}

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

.card-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.toggle-actions {
    display: flex;
    gap: 6px;
}

.btn-sm {
    padding: 5px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-sm:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger:hover {
    border-color: var(--red);
    color: var(--red);
}

.import-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text);
    transition: border-color var(--transition);
}

.import-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.import-input::placeholder {
    color: var(--text-muted);
}

/* API Grid */
.api-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
}

.api-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    cursor: default;
}

.api-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.api-info {
    flex: 1;
    min-width: 0;
}

.api-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.api-desc {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
    margin-left: 10px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--red-dim);
    border: 1px solid var(--red);
    border-radius: 24px;
    cursor: pointer;
    transition: all var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--red);
    border-radius: 50%;
    transition: all var(--transition);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--green-dim);
    border-color: var(--green);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(18px);
    background: var(--green);
}

.toggle-switch input:focus+.toggle-slider {
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Value select for more granular control */
.api-value {
    padding: 4px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.72rem;
    font-family: var(--font-sans);
    margin-left: 6px;
}

.api-value option {
    background: var(--bg-card);
}

/* Output */
.output-block {
    margin-bottom: 14px;
}

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

.output-label span {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
}

.btn-copy {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-copy:hover {
    border-color: var(--green);
    color: var(--green);
    background: var(--green-dim);
}

.output-code {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--primary);
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.6;
    overflow-x: auto;
    min-height: 36px;
}

/* Test Results */
.test-results {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.test-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
}

.test-item .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-allowed {
    background: var(--green);
}

.status-denied {
    background: var(--red);
}

.status-unknown {
    background: var(--yellow);
}

.footer {
    text-align: center;
    margin-top: 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--bg-card);
    border: 1px solid var(--green);
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-size: 0.82rem;
    color: var(--green);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
    z-index: 100;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 520px) {
    .app {
        padding: 16px 10px 32px;
    }

    .api-grid {
        grid-template-columns: 1fr;
    }

    .header-title {
        font-size: 1.1rem;
    }
}