/**
 * SSL Tools — Standalone styles
 * Used on sensitive tool pages (no Tailwind CDN, no base.html).
 * Light theme by default, dark mode via body.theme-dark class.
 * Aligned with main site Element UI design system.
 */

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { line-height: 1.5; -webkit-text-size-adjust: 100%; font-family: 'DM Sans', system-ui, -apple-system, sans-serif; }
body { min-height: 100vh; }
a { color: inherit; text-decoration: none; }
img, svg { display: inline-block; max-width: 100%; }
svg:not([width]) { width: 1em; height: 1em; }
button, input, textarea, select { font: inherit; color: inherit; }
pre { font-family: 'JetBrains Mono', 'IBM Plex Mono', monospace; }

/* ===== CSS Variables — Light (Element UI palette, default) ===== */
:root {
    --page-bg: #f5f7fa;
    --surface: #ffffff;
    --text-primary: #303133;
    --text-secondary: #606266;
    --text-muted: #909399;
    --accent: #409eff;
    --accent-hover: #66b1ff;
    --nav-bg: #ffffff;
    --nav-border: #dcdfe6;
    --card-bg: #ffffff;
    --card-border: #e4e7ed;
    --input-bg: #ffffff;
    --input-border: #dcdfe6;
    --input-text: #303133;
    --btn-primary-bg: #409eff;
    --btn-primary-text: #ffffff;
    --surface-border: #dcdfe6;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    --success: #67c23a;
    --warning: #e6a23c;
    --danger: #f56c6c;
}

/* ===== CSS Variables — Dark (via body class from site toggle) ===== */
body.theme-dark {
    --page-bg: #141414;
    --surface: #1d1e1f;
    --text-primary: #e5eaf3;
    --text-secondary: #a3a6ad;
    --text-muted: #73767a;
    --accent: #409eff;
    --accent-hover: #66b1ff;
    --nav-bg: #1d1e1f;
    --nav-border: #4c4d4f;
    --card-bg: #1d1e1f;
    --card-border: #4c4d4f;
    --input-bg: #2c2c2c;
    --input-border: #4c4d4f;
    --input-text: #e5eaf3;
    --btn-primary-bg: #409eff;
    --btn-primary-text: #ffffff;
    --surface-border: #4c4d4f;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

body { background: var(--page-bg); color: var(--text-primary); }

/* ===== Nav ===== */
.csr-nav {
    position: sticky; top: 0; z-index: 100;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    box-shadow: var(--shadow-sm);
}
.csr-nav-inner {
    max-width: 80rem; margin: 0 auto; padding: 0 1.5rem;
    display: flex; align-items: center; justify-content: space-between; height: 56px;
}
.csr-nav-brand { display: flex; align-items: center; gap: 0.5rem; }
.csr-nav-brand svg { width: 24px; height: 24px; color: var(--accent); }
.csr-nav-brand span { font-weight: 700; font-size: 1rem; color: var(--text-primary); }
.csr-nav-links { display: flex; align-items: center; gap: 1.5rem; }
.csr-nav-links a { font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); transition: color 0.15s; }
.csr-nav-links a:hover { color: var(--accent); }

/* ===== Theme Toggle ===== */
.theme-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    border: 1px solid var(--card-border); background: var(--card-bg);
    cursor: pointer; transition: border-color 0.15s;
    color: var(--text-secondary);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }

/* ===== Secure Banner ===== */
.secure-banner {
    background: rgba(103, 194, 58, 0.06);
    border-bottom: 1px solid rgba(103, 194, 58, 0.12);
    padding: 0.375rem 0; text-align: center;
    font-size: 0.75rem; color: var(--success); font-weight: 500;
    display: flex; align-items: center; justify-content: center; gap: 0.375rem;
}

/* ===== Security Details ===== */
.security-details {
    background: var(--card-bg); border: 1px solid rgba(103, 194, 58, 0.2); border-radius: var(--radius-lg);
}
.security-details > summary { cursor: pointer; list-style: none; }
.security-details > summary::-webkit-details-marker { display: none; }
.security-details[open] > summary .chevron { transform: rotate(180deg); }
.security-details[open] > summary { border-bottom: 1px solid var(--card-border); }

/* ===== Container ===== */
.container { max-width: 80rem; margin: 0 auto; padding: 0 1rem; }
@media (min-width: 640px) { .container { padding: 0 1.5rem; } }

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

/* ===== Form Inputs ===== */
.input {
    width: 100%; padding: 0.625rem 1rem; border-radius: var(--radius-sm);
    font-size: 0.875rem; background: var(--input-bg);
    border: 1px solid var(--input-border); color: var(--input-text);
    outline: none; transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.15); }
textarea.input { resize: vertical; }

/* ===== Radio Cards ===== */
.radio-card {
    position: relative; display: flex; flex-direction: column;
    padding: 1rem; border-radius: var(--radius-md); cursor: pointer;
    border: 1px solid var(--card-border); transition: border-color 0.15s;
}
.radio-card input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.radio-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* ===== Buttons ===== */
.btn-primary {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.625rem 1.5rem; border-radius: var(--radius-sm);
    font-size: 0.875rem; font-weight: 600;
    background: var(--btn-primary-bg); color: var(--btn-primary-text);
    border: none; cursor: pointer; transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-sm {
    display: inline-flex; align-items: center; gap: 0.375rem;
    padding: 0.375rem 0.75rem; border-radius: var(--radius-sm);
    font-size: 0.75rem; font-weight: 500;
    cursor: pointer; border: none; transition: opacity 0.15s;
}
.btn-sm:hover { opacity: 0.85; }

/* ===== Alerts ===== */
.alert { border-radius: var(--radius-md); padding: 1rem; display: flex; align-items: flex-start; gap: 0.75rem; }
.alert-green { background: rgba(103, 194, 58, 0.08); border: 1px solid rgba(103, 194, 58, 0.15); }
.alert-red { background: rgba(245, 108, 108, 0.08); border: 1px solid rgba(245, 108, 108, 0.2); }
.alert-amber { background: rgba(230, 162, 60, 0.08); border: 1px solid rgba(230, 162, 60, 0.15); }

/* ===== Output Blocks ===== */
.output-block { border-radius: var(--radius-md); overflow: hidden; }
.output-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1rem; flex-wrap: wrap; gap: 0.5rem;
}
.output-pre {
    padding: 1rem; overflow-x: auto;
    font-size: 0.75rem; line-height: 1.625;
    font-family: 'JetBrains Mono', 'IBM Plex Mono', monospace;
    background: var(--card-bg); color: var(--text-primary);
    white-space: pre-wrap; word-break: break-all;
}
.output-danger { border: 1px solid rgba(245, 108, 108, 0.2); }
.output-danger .output-header { background: rgba(245, 108, 108, 0.06); border-bottom: 1px solid rgba(245, 108, 108, 0.15); }
.output-safe { border: 1px solid var(--card-border); }
.output-safe .output-header { background: var(--surface); border-bottom: 1px solid var(--card-border); }

/* ===== Details/Summary ===== */
details { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-md); }
details > summary { cursor: pointer; list-style: none; padding: 1.5rem; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary .chevron { transform: rotate(180deg); }
details .details-body { padding: 0 1.5rem 1.5rem; }

/* ===== Breadcrumb ===== */
.breadcrumb { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--text-muted); flex-wrap: wrap; }
.breadcrumb a { color: var(--accent); }
.breadcrumb a:hover { text-decoration: underline; }

/* ===== Grid layout ===== */
.grid-form { display: grid; gap: 2rem; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .grid-form { grid-template-columns: 2fr 1fr; } }
.grid-stats { display: grid; gap: 1rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .grid-stats { grid-template-columns: repeat(4, 1fr); } }
.grid-keys { display: grid; gap: 0.75rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .grid-keys { grid-template-columns: repeat(4, 1fr); } }
.grid-org { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-org { grid-template-columns: repeat(2, 1fr); } }

/* ===== Step Numbers ===== */
.step-num {
    flex-shrink: 0; width: 1.25rem; height: 1.25rem; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700; background: var(--accent); color: white;
}

/* ===== Footer ===== */
.csr-footer {
    margin-top: 3rem; padding: 1.5rem 0;
    border-top: 1px solid var(--card-border);
    text-align: center; font-size: 0.75rem; color: var(--text-muted);
}
.csr-footer a { color: var(--accent); }

/* ===== Utility ===== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.flex-shrink-0 { flex-shrink: 0; }
