/* ==========================================================================
   BulkCerts Studio — Premium Obsidian Design System & Responsive Styling
   ========================================================================== */

:root {
    --bg-base: #030712;        /* Deep Obsidian */
    --bg-panel: rgba(10, 15, 30, 0.75);
    --bg-card: rgba(17, 24, 39, 0.45);
    --bg-input: rgba(3, 7, 18, 0.6);
    
    --border-color: rgba(255, 255, 255, 0.06);
    --border-focus: rgba(6, 182, 212, 0.6);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #475569;
    
    /* Neon Gradients */
    --primary: #06b6d4;        /* Electric Cyan */
    --secondary: #3b82f6;      /* Bright Blue */
    --accent: #10b981;         /* Emerald */
    --danger: #ef4444;         /* Neon Red */
    
    --gradient-primary: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --gradient-gold: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-emerald: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-danger: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
    
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
    
    --font-ui: 'Plus Jakarta Sans', system-ui, sans-serif;
}

/* ==========================================================================
   Core Layout & Ambient Glow Background
   ========================================================================== */

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-base);
    color: var(--text-primary);
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
    width: 100vw;
    position: relative;
}

/* Ambient glow blobs */
.ambient-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 1;
    pointer-events: none;
    opacity: 0.15;
}

.glow-1 {
    width: min(500px, 80vw);
    height: min(500px, 80vw);
    background: #06b6d4;
    top: -100px;
    left: -100px;
    animation: drift 25s infinite alternate ease-in-out;
}

.glow-2 {
    width: min(600px, 90vw);
    height: min(600px, 90vw);
    background: #4f46e5;
    bottom: -150px;
    right: 10%;
    animation: drift 30s infinite alternate-reverse ease-in-out;
}

.glow-3 {
    width: min(400px, 70vw);
    height: min(400px, 70vw);
    background: #db2777;
    top: 30%;
    right: -100px;
    animation: drift 20s infinite alternate ease-in-out;
}

@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(60px, 40px) scale(1.1); }
    100% { transform: translate(-20px, -30px) scale(0.95); }
}

/* Base Studio Layout */
.app-studio {
    display: flex;
    flex-direction: row;
    position: relative;
    z-index: 2;
    min-height: 100vh;
    width: 100vw;
}

/* ==========================================================================
   Left and Right Sidebars
   ========================================================================== */

.panel {
    width: 340px;
    background-color: var(--bg-panel);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.panel-right {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.brand {
    padding: 22px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
}

.brand-logo {
    width: 42px;
    height: 42px;
    background: var(--gradient-primary);
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    box-shadow: 0 4px 20px rgba(6, 182, 212, 0.35);
}

.brand h1 {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.4px;
    background: linear-gradient(to right, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-tagline {
    font-size: 11px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 1px;
    font-weight: 600;
    opacity: 0.95;
}

.panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel-scroll::-webkit-scrollbar {
    width: 5px;
}
.panel-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.panel-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}
.panel-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

.flex-grow {
    flex-grow: 1;
}

.panel-bottom-card {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Center Creative Workspace
   ========================================================================== */

.studio-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.workspace-header {
    padding: 16px 28px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

.workspace-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.workspace-header .subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.canvas-viewport-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 2vw, 30px);
    background-color: rgba(3, 7, 18, 0.45);
    background-image: radial-gradient(rgba(255, 255, 255, 0.02) 1.5px, transparent 1.5px);
    background-size: 28px 28px;
    overflow: hidden; 
    width: 100%;
}

.canvas-container {
    position: relative;
    border-radius: 12px;
    box-shadow: 0 35px 80px -20px rgba(0, 0, 0, 0.85);
    background: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    transition: transform 0.3s ease;
}

.canvas-container:hover {
    transform: scale(1.002);
}

#preview-canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 297/210;
    border-radius: 11px;
}

.workspace-tip {
    margin-top: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 12px;
    color: var(--text-secondary);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.workspace-tip i {
    color: var(--primary);
    flex-shrink: 0;
}

.workspace-tip b {
    color: var(--text-primary);
}

/* ==========================================================================
   Studio Cards & Inputs
   ========================================================================== */

.studio-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.25s ease;
}

.studio-card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.01);
}

.step-badge {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid var(--primary);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
}

.studio-card-header h3 {
    font-size: 13.5px;
    font-weight: 600;
}

.studio-card-body {
    padding: 16px;
}

.w-full {
    width: 100%;
}

.mt-3 {
    margin-top: 12px;
}

.mb-3 {
    margin-bottom: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 12.5px;
    font-weight: 600;
    font-family: var(--font-ui);
    border-radius: var(--border-radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1.5px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.5);
    filter: brightness(1.1);
}

.btn-primary:disabled {
    background: #1e293b;
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
}

.btn-outline-danger {
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-outline-danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239, 68, 68, 0.04);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-lg {
    padding: 13px 22px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.icon-btn-danger {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s;
}

.icon-btn-danger:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.element-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Forms */
.form-group {
    margin-bottom: 14px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-select, .form-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 12.5px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    outline: none;
    font-family: var(--font-ui);
    transition: all 0.2s ease;
}

.form-select:focus, .form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

textarea.form-input {
    resize: none;
}

/* Upload zones */
.upload-zone {
    border: 1.5px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-md);
    padding: 22px 14px;
    text-align: center;
    background: rgba(255, 255, 255, 0.01);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: rgba(6, 182, 212, 0.03);
}

.pulsing-circle {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-secondary);
}

.upload-title {
    font-size: 12px;
    font-weight: 600;
}

.upload-desc {
    font-size: 11px;
    color: var(--text-secondary);
}

.upload-desc span {
    color: var(--primary);
    font-weight: 600;
}

.upload-zone.compact {
    padding: 12px;
    flex-direction: row;
    justify-content: center;
    gap: 8px;
}

.excel-status-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(16, 185, 129, 0.07);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--border-radius-md);
    margin-bottom: 12px;
}

.excel-status-meta {
    display: flex;
    flex-direction: column;
}

.excel-status-banner .file-name {
    font-size: 11.5px;
    font-weight: 700;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.excel-status-banner .file-name i {
    color: var(--accent);
}

.excel-status-banner .row-count {
    font-size: 10px;
    color: var(--text-secondary);
}

.dynamic-fields {
    margin-top: 14px;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}

.panel-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.field-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.field-tag {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.25);
    color: #a5f3fc;
    padding: 5px 8px;
    border-radius: var(--border-radius-sm);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Properties Inspector Panels */
.inspector-card {
    background: var(--bg-card);
    border: 1px solid rgba(6, 182, 212, 0.25);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 4px 25px rgba(6, 182, 212, 0.05);
    overflow: hidden;
}

.inspector-header {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(6, 182, 212, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(6, 182, 212, 0.03);
}

.inspector-header i {
    color: var(--primary);
}

.inspector-header h3 {
    font-size: 13.5px;
    font-weight: 600;
}

.inspector-body {
    padding: 16px;
}

.form-row {
    display: flex;
    gap: 10px;
}

.col-6 {
    flex: 0 0 calc(50% - 5px);
}

.btn-group-toggle {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 2px;
    height: 36px;
}

.btn-toggle-icon {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: calc(var(--border-radius-md) - 2px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11.5px;
}

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

.color-picker-wrapper {
    display: flex;
    gap: 8px;
}

.color-picker {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background: transparent;
    cursor: pointer;
}

.hex-input {
    flex: 1;
    font-family: monospace;
    font-size: 12px;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="range"] {
    flex: 1;
    height: 4px;
    accent-color: var(--primary);
}

.slider-value {
    font-size: 11px;
    font-weight: 700;
    min-width: 44px;
    text-align: right;
}

.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 26px;
    cursor: pointer;
    font-size: 11.5px;
    color: var(--text-secondary);
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    height: 16px;
    width: 16px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 5px;
    top: 2px;
    width: 3.5px;
    height: 7.5px;
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.progress-section {
    margin-top: 14px;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    margin-bottom: 5px;
}

#progress-percentage {
    color: var(--primary);
    font-weight: 700;
}

.progress-bar-bg {
    height: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 5px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
}

.progress-counter {
    font-size: 10px;
    color: var(--text-muted);
    text-align: right;
}

/* ==========================================================================
   Data Table Preview
   ========================================================================== */

.data-grid-section {
    padding: 16px 28px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

.data-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
}

.data-grid-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.data-grid-title i {
    color: var(--primary);
}

.badge {
    padding: 3px 8px;
    font-size: 9px;
    font-weight: 700;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    text-transform: uppercase;
}

.badge.active {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.2);
}

.row-pager {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 3px 6px;
}

.pager-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pager-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.pager-text {
    font-size: 11px;
    color: var(--text-secondary);
}

.table-outer-wrapper {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
}

.table-container {
    height: 105px;
    overflow-x: auto;
    overflow-y: auto;
    background: rgba(3, 7, 18, 0.2);
}

.table-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 6px;
    color: var(--text-muted);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
}

.data-table th, .data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table th {
    background-color: rgba(3, 7, 18, 0.7);
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table tbody tr.selected-row {
    background-color: rgba(6, 182, 212, 0.05);
}

.data-table tbody tr.selected-row td {
    color: var(--primary);
}

.hidden {
    display: none !important;
}

.boot-error {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: min(640px, calc(100vw - 32px));
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    background: rgba(127, 29, 29, 0.95);
    border: 1px solid rgba(248, 113, 113, 0.45);
    color: #fecaca;
    font-size: 13px;
    font-weight: 600;
}

/* ==========================================================================
   DYNAMIC MEDIA QUERIES FOR COMPACT SCREENS & SMART PHONES
   ========================================================================== */

@media (max-width: 1400px) {
    .canvas-container {
        max-width: 100%;
    }
}

/* Tablets & Ultra-wide mobile layouts */
@media (max-width: 1120px) {
    body {
        overflow-y: auto;
    }

    .app-studio {
        flex-direction: column;
        height: auto;
        overflow-y: visible;
    }

    /* breakout the left sidebar wrapper into a full-width block */
    .panel {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    /* Force the .brand wrapper to stay at the extreme top of .app-studio flex row */
    .panel .brand {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 50;
        border-bottom: 1px solid var(--border-color);
        background: var(--bg-panel);
        backdrop-filter: blur(25px);
        -webkit-backdrop-filter: blur(25px);
    }

    /* Offset layout content so the sticky branding logo doesn't overlap text inputs */
    .panel-left {
        padding-top: 87px; 
    }

    .panel-right {
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .studio-workspace {
        height: auto;
        width: 100%;
    }
}

/* Compact Smartphone Layout Scale Fix */
@media (max-width: 640px) {
    .canvas-viewport-container {
        padding: 8px;
    }
    
    /* Clean CSS transformation scaling keeps premium desktop certificate styling readable on phone screens */
    .canvas-container {
        max-width: 100%;
        transform: scale(0.95);
        transform-origin: center center;
    }

    .workspace-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px;
    }

    .header-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-top: 10px;
    }

    .header-actions .btn {
        width: 100%;
        font-size: 11px;
        padding: 10px 6px;
    }

    .data-grid-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .row-pager {
        width: 100%;
        justify-content: space-between;
        margin-top: 8px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .col-6 {
        flex: 0 0 100%;
    }

    .element-buttons {
        grid-template-columns: 1fr;
    }
}