/* ============================================================
   eforms99_python — Common Design System
   ------------------------------------------------------------
   Shared styles for all modules:
       - docx2pdf
       - rghs
       - clear_document
       - pdf_tools
   ============================================================ */

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
    /* Primary colors */
    --primary: #e11d48;
    --primary-hover: #be123c;
    --primary-light: #fff1f2;
    --primary-border: #fecdd3;
    --primary-glow: rgba(225, 29, 72, 0.15);

    /* Success / Warning / Error */
    --success: #059669;
    --success-light: #ecfdf5;
    --success-border: #a7f3d0;

    --warning: #d97706;
    --warning-light: #fffbeb;
    --warning-border: #fef3c7;

    --error: #dc2626;
    --error-light: #fef2f2;
    --error-border: #fecaca;

    --info: #2563eb;
    --info-light: #eff6ff;
    --info-border: #bfdbfe;

    /* Backgrounds */
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-muted: #f1f5f9;

    /* Text */
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Borders */
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-card: 0 10px 25px -5px rgba(15, 23, 42, 0.06),
                   0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --shadow-hover: 0 16px 32px -8px rgba(15, 23, 42, 0.1),
                    0 6px 12px -4px rgba(15, 23, 42, 0.05);

    /* Font */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
                   Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ============================================================
   RESET
   ============================================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-family);
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}
.page.narrow { max-width: 820px; }
.page.wide { max-width: 1400px; }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb { margin-bottom: 24px; }

.breadcrumb a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.breadcrumb a:hover {
    color: var(--primary);
    border-color: var(--primary-border);
    background: var(--primary-light);
    transform: translateX(-2px);
}

/* ============================================================
   PANEL / CARD
   ============================================================ */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

@media (max-width: 640px) {
    .panel { padding: 32px 20px; }
}

.panel-header {
    text-align: center;
    max-width: 600px;
    margin: 0 auto 36px;
}

/* ============================================================
   TOOL ICON WRAPPER
   ============================================================ */
.tool-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    font-size: 36px;
    background: var(--primary-light);
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-main);
    margin-bottom: 12px;
}

h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
    margin-bottom: 12px;
}

h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

.subtitle {
    font-size: 16px;
    color: var(--text-muted);
    line-height: 1.6;
}

@media (max-width: 640px) {
    h1 { font-size: 26px; }
    h2 { font-size: 20px; }
    .subtitle { font-size: 15px; }
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: -2px;
    line-height: 1.4;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 11px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-main);
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all 0.15s ease;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.file-hidden-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

/* ============================================================
   DROPZONE
   ============================================================ */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px 24px;
    border: 2px dashed var(--border-hover);
    border-radius: var(--radius-md);
    background: var(--bg-page);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.dropzone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.dropzone.has-file { display: none; }

.dropzone-icon { font-size: 34px; line-height: 1; }

.dropzone-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
}

.dropzone-hint {
    font-size: 12.5px;
    color: var(--text-muted);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14.5px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    white-space: nowrap;
}

.btn:disabled {
    background: var(--text-light) !important;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(225, 29, 72, 0.25);
}

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover:not(:disabled) {
    background: #047857;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-muted);
    color: var(--text-main);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-block {
    width: 100%;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 700;
}

/* ============================================================
   STATUS MESSAGES
   ============================================================ */
.status {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    display: none;
    margin-top: 12px;
}
.status.visible { display: block; }
.status-info { background: var(--info-light); color: var(--info); border: 1px solid var(--info-border); }
.status-success { background: var(--success-light); color: var(--success); border: 1px solid var(--success-border); }
.status-error { background: var(--error-light); color: var(--error); border: 1px solid var(--error-border); }
.status-warning { background: var(--warning-light); color: var(--warning); border: 1px solid var(--warning-border); }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress {
    display: none;
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 9999px;
    overflow: hidden;
    margin-top: 10px;
}
.progress.visible { display: block; }

.progress-bar {
    height: 100%;
    width: 35%;
    background: var(--primary);
    border-radius: 9999px;
    animation: progress-slide 1.2s ease-in-out infinite;
}

@keyframes progress-slide {
    0% { margin-left: -35%; }
    100% { margin-left: 100%; }
}

/* ============================================================
   NOT READY / PLACEHOLDER
   ============================================================ */
.not-ready {
    background: var(--warning-light);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius-md);
    padding: 44px 28px;
    text-align: center;
}

.not-ready .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: var(--warning-border);
    border-radius: 50%;
    font-size: 28px;
    margin-bottom: 16px;
}

.not-ready b {
    font-size: 19px;
    color: #92400e;
    font-weight: 700;
    display: block;
}

.not-ready .desc {
    margin-top: 8px;
    font-size: 14.5px;
    color: #b45309;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

/* ============================================================
   PREVIEW CARD
   ============================================================ */
.preview-card {
    display: none;
    position: relative;
    padding: 20px;
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
}
.preview-card.visible { display: block; }

.preview-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    background: #fff;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.preview-canvas {
    display: block;
    max-width: 240px;
    max-height: 320px;
    border-radius: 6px;
    background: #fff;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.preview-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    z-index: 5;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: #fff;
    color: var(--text-main);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.icon-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    transform: scale(1.08);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.preview-filename {
    margin-top: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    word-break: break-all;
}

.preview-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 10px;
    background: var(--primary-light);
    border: 1px solid var(--primary-border);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
}

/* ============================================================
   ROTATION BUTTONS
   ============================================================ */
.rotation-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rotation-btn {
    display: flex;
    align-items: stretch;
    padding: 0;
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    text-align: left;
    overflow: hidden;
    height: 56px;
}

.rotation-btn:hover {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.rotation-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    background: var(--primary);
    color: #fff;
    flex-shrink: 0;
}

.rotation-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.rotation-text {
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ============================================================
   TOOL GRID (for index pages)
   ============================================================ */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.tool-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.2s ease;
    position: relative;
}

.tool-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: var(--border-hover);
}

.tool-card.unavailable { opacity: 0.6; }

.tool-card .icon { font-size: 28px; margin-bottom: 4px; }
.tool-card .name { font-weight: 700; font-size: 15px; }
.tool-card .desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.tool-card .badge {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 6px;
}

.tool-card.available .badge {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.tool-card.unavailable .badge {
    background: var(--bg-muted);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.category { margin-bottom: 40px; }

.category h2 {
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #334155;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 18px;
}

/* ============================================================
   UTILITY
   ============================================================ */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }

.spin {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
    .page { padding: 24px 16px 60px; }
    .tools-grid { grid-template-columns: 1fr; }
}