/* EntryZen Gate Simulator - Shared Styles */

:root {
    --primary-color: #ff5733;
    --primary-hover: #f7421a;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
}

/* Navigation */
.navbar {
    background: white;
    box-shadow: var(--shadow);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo svg {
    width: 32px;
    height: 32px;
}

.logo img {
    height: 32px;
    width: auto;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
}

.nav-links a {
    color: var(--gray-600);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary-color);
    background: var(--gray-100);
}

/* Main Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--gray-900);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-icon {
    padding: 0.5rem;
    width: 36px;
    height: 36px;
    justify-content: center;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem 1.5rem;
    text-align: left;
}

th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-200);
}

td {
    border-bottom: 1px solid var(--gray-100);
}

tr:hover td {
    background: var(--gray-50);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-primary {
    background: rgba(255, 87, 51, 0.1);
    color: #c4391c;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-gray {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* Device ID Badge */
.device-id {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.875rem;
    background: var(--gray-100);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: var(--gray-700);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: white;
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 87, 51, 0.1);
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-checkbox input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary-color);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

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

.modal {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.3s;
}

.modal-backdrop.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 0.25rem;
    display: flex;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--gray-600);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Alert Messages */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-info {
    background: rgba(255, 87, 51, 0.08);
    color: #c4391c;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--gray-500);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

/* Action Buttons in Table */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--gray-300);
    border-radius: 24px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-slider {
    background-color: var(--success-color);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Gate Type Icons */
.gate-type {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gate-type svg {
    width: 20px;
    height: 20px;
    color: var(--gray-500);
}

/* Visualization Grid */
.viz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

/* Gate Tile */
.gate-tile {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.3s;
}

.gate-tile:hover {
    box-shadow: var(--shadow-md);
}

.gate-tile-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gate-tile-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.gate-tile-info .device-id {
    font-size: 0.75rem;
}

.gate-tile-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gray-300);
}

.status-dot.online {
    background: var(--success-color);
}

.status-dot.offline {
    background: var(--danger-color);
}

.status-dot.moving {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.gate-tile-body {
    padding: 1.5rem;
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.gate-visualization {
    flex: 1;
    aspect-ratio: 4/3;
    background: var(--gray-100);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gate-visualization svg {
    width: 100%;
    height: 100%;
}

.gate-3d-container {
    width: 100%;
    height: 100%;
    min-height: 200px;
}

.gate-3d-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Remote Control Widget */
.remote-control {
    width: 100px;
    background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.remote-brand {
    color: #888;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.remote-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-600);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
    transition: all 0.3s;
}

.remote-led.online {
    background: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

.remote-led.offline {
    background: var(--danger-color);
    box-shadow: 0 0 8px var(--danger-color);
}

.remote-led.moving {
    background: var(--success-color);
    animation: led-blink 0.5s infinite;
}

@keyframes led-blink {
    0%, 100% { 
        opacity: 1;
        box-shadow: 0 0 12px var(--success-color);
    }
    50% { 
        opacity: 0.3;
        box-shadow: 0 0 4px var(--success-color);
    }
}

.remote-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, #4a4a4a, #3a3a3a);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.remote-button:hover {
    background: linear-gradient(145deg, #5a5a5a, #4a4a4a);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        0 0 20px rgba(255, 87, 51, 0.3);
}

.remote-button:active {
    transform: scale(0.95);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.remote-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.remote-button svg {
    width: 24px;
    height: 24px;
    color: #ccc;
}

.gate-tile-footer {
    padding: 0.75rem 1.25rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.position-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.position-status.closed { color: var(--gray-600); }
.position-status.open { color: var(--success-color); }
.position-status.opening, .position-status.closing { color: var(--warning-color); }

/* Gate Selector */
.gate-selector {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.gate-selector-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gate-selector-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.gate-selector-body {
    padding: 1rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.gate-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.gate-checkbox:hover {
    background: var(--gray-100);
}

.gate-checkbox input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary-color);
}

.gate-checkbox-label {
    font-size: 0.875rem;
}

.gate-checkbox-id {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-family: monospace;
}

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, #c4391c 0%, #ff5733 100%);
    color: white;
    margin: -2rem -2rem 2rem -2rem;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.125rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.hero .btn {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

/* Feature Cards */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.feature-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.feature-card svg {
    width: 48px;
    height: 48px;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--gray-600);
    font-size: 0.875rem;
}

/* API Docs Styles */
.api-section {
    margin-bottom: 2rem;
}

.api-endpoint {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.api-endpoint-header {
    padding: 1rem 1.5rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.api-method {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.api-method.post {
    background: #dcfce7;
    color: #166534;
}

.api-method.get {
    background: rgba(255, 87, 51, 0.1);
    color: #c4391c;
}

.api-path {
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--gray-700);
}

.api-endpoint-body {
    padding: 1.5rem;
}

.code-block {
    background: var(--gray-800);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.code-block code {
    color: #e5e7eb;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
}

.code-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: 0.5rem;
}

.code-tab {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    border-radius: var(--radius) var(--radius) 0 0;
    transition: all 0.2s;
}

.code-tab:hover {
    color: var(--gray-700);
}

.code-tab.active {
    color: var(--primary-color);
    background: var(--gray-100);
}

/* Try It Section */
.try-it {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.try-it h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.try-it-result {
    margin-top: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .gate-tile-body {
        flex-direction: column;
    }
    
    .remote-control {
        width: 100%;
        max-width: 120px;
    }
    
    .hero {
        padding: 2rem 1rem;
    }
    
    .hero h1 {
        font-size: 1.75rem;
    }
    
    .hero-buttons {
        flex-direction: column;
    }
}

/* Gate Placement Editor */
.placement-editor {
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 1rem;
}

.placement-editor-header {
    margin-bottom: 1rem;
    text-align: center;
}

.placement-editor-header h4 {
    font-size: 1rem;
    color: var(--gray-800);
    margin-bottom: 0.25rem;
}

.placement-editor-header p {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.placement-canvas {
    position: relative;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: crosshair;
    user-select: none;
    min-height: 300px;
}

.placement-canvas.loading::after {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.placement-bg {
    display: block;
    width: 100%;
    height: auto;
    min-height: 200px;
    max-height: 500px;
    object-fit: contain;
    background: #1a1a2e;
    height: auto;
    display: block;
    pointer-events: none;
}

.gate-overlay {
    position: absolute;
    cursor: move;
    border: 2px dashed var(--primary-color);
    box-sizing: border-box;
    transform: translate(-50%, -50%);
}

.gate-overlay:hover {
    border-color: var(--success-color);
}

.gate-overlay img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.resize-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border: 2px solid white;
    border-radius: 50%;
    cursor: se-resize;
}

.resize-handle-se {
    bottom: -8px;
    right: -8px;
}

.resize-handle-sw {
    bottom: -8px;
    left: -8px;
    cursor: sw-resize;
}

.resize-handle:hover {
    background: var(--success-color);
    transform: scale(1.2);
}

/* Double-leaf gate overlays (separate left/right) */
.leaf-overlay {
    border-color: var(--primary-color);
}

/* Barrier overlays (post and arm) */
.barrier-overlay {
    border-color: var(--primary-color);
}

#barrierPostOverlay {
    border-color: #8b5cf6; /* Purple for post */
    z-index: 5;
}

#barrierArmOverlay {
    border-color: #f59e0b; /* Orange for arm */
    z-index: 6;
}

.barrier-label {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

#barrierPostOverlay .barrier-label {
    background: #8b5cf6;
}

#barrierArmOverlay .barrier-label {
    background: #f59e0b;
}

/* Pivot point indicator */
.pivot-point {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--danger-color);
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    pointer-events: none;
}

/* Barrier controls layout */
.barrier-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.barrier-control-section {
    flex: 1;
    min-width: 180px;
}

.barrier-control-section h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: 0.5rem;
}

.barrier-control-section .help-text {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-bottom: 0.75rem;
}

.hide-post-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--gray-300);
}

.hide-post-control span {
    font-size: 0.8rem;
    color: var(--gray-600);
}

.aspect-lock-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
    padding: 0.5rem 0;
    border-top: 1px dashed var(--gray-200);
    border-bottom: 1px dashed var(--gray-200);
}

.aspect-lock-control span {
    font-size: 0.8rem;
    color: var(--gray-600);
}

#postControls {
    transition: opacity 0.2s ease;
}

#leftLeafOverlay {
    border-color: #3b82f6; /* Blue for left */
}

#rightLeafOverlay {
    border-color: #10b981; /* Green for right */
}

/* Right leaf flip is controlled via JavaScript based on toggle */
#rightLeafOverlay img.flipped {
    transform: scaleX(-1);
}

.leaf-label {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

#leftLeafOverlay .leaf-label {
    background: #3b82f6;
}

#rightLeafOverlay .leaf-label {
    background: #10b981;
}

/* Double-leaf controls layout */
.double-leaf-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.leaf-controls-row {
    display: flex;
    gap: 12px;
}

.leaf-controls-section {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-left: 3px solid #3b82f6;
}

.leaf-controls-section.right-leaf {
    border-left-color: #10b981;
}

/* Hinge controls */
.hinge-control {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.hinge-buttons {
    display: flex;
    gap: 6px;
}

.hinge-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.hinge-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.hinge-indicator {
    display: inline-block;
    width: 3px;
    height: 14px;
    background: currentColor;
    border-radius: 2px;
}

.hinge-indicator.left {
    margin-right: 2px;
}

.hinge-indicator.right {
    margin-left: 2px;
}

/* Visual hinge indicator on gate overlay */
.gate-overlay .hinge-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--danger-color);
    z-index: 10;
    transition: left 0.15s ease, right 0.15s ease;
    box-shadow: 0 0 6px rgba(255, 68, 68, 0.5);
}

.gate-overlay .hinge-line.left {
    border-radius: 2px 0 0 2px;
}

.gate-overlay .hinge-line.right {
    border-radius: 0 2px 2px 0;
}

/* Crop controls */
.crop-controls {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.crop-controls > label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.crop-controls .help-text {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.crop-sliders {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.crop-slider-group {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
}

.crop-slider-group span:first-child {
    width: 45px;
    color: var(--text-muted);
}

.crop-slider-group input[type="range"] {
    flex: 1;
    height: 4px;
}

.crop-slider-group span:last-child {
    width: 30px;
    text-align: right;
    color: var(--text-primary);
}

.double-leaf-crop {
    grid-column: 1 / -1;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
}

/* Scale controls group */
.scale-controls-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    margin-bottom: 8px;
}

/* Aspect lock control */
.aspect-lock-control {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255, 87, 51, 0.1);
    border: 1px solid rgba(255, 87, 51, 0.3);
    border-radius: 6px;
    font-size: 0.8rem;
}

.aspect-lock-control .lock-label {
    color: var(--text-primary);
}

.aspect-lock-control .lock-icon {
    color: var(--primary-color);
    margin-left: auto;
}

.aspect-lock-control:has(input:not(:checked)) {
    background: rgba(100, 100, 100, 0.1);
    border-color: rgba(100, 100, 100, 0.3);
}

.aspect-lock-control:has(input:not(:checked)) .lock-icon {
    opacity: 0.3;
}

/* Double leaf toggles row */
.double-leaf-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.double-leaf-toggles .link-scales-control,
.double-leaf-toggles .aspect-lock-control {
    flex: 1;
    min-width: 120px;
}

/* Link scales control */
.link-scales-control {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255, 87, 51, 0.1);
    border: 1px solid rgba(255, 87, 51, 0.3);
    border-radius: 6px;
    font-size: 0.8rem;
}

.link-scales-control .link-label {
    color: var(--text-primary);
}

.link-scales-control .link-icon {
    color: var(--primary-color);
    margin-left: auto;
}

.link-scales-control:has(input:not(:checked)) {
    background: rgba(100, 100, 100, 0.1);
    border-color: rgba(100, 100, 100, 0.3);
}

.link-scales-control:has(input:not(:checked)) .link-icon {
    opacity: 0.3;
}

/* Test animation button */
.test-animation-control {
    margin-top: 12px;
}

.test-animation-control.canvas-test-btn {
    display: flex;
    justify-content: center;
    margin: 12px 0;
}

.test-animation-control.canvas-test-btn .test-btn {
    width: auto;
    padding: 8px 24px;
}

.test-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.test-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-1px);
}

.test-btn:disabled {
    background: #4b5563;
    cursor: not-allowed;
    transform: none;
}

.test-btn svg {
    flex-shrink: 0;
}

/* Gate animation styles */
.gate-overlay.animating {
    pointer-events: none;
}

.gate-overlay .gate-image-wrapper {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    perspective: 800px;
}

.gate-overlay img {
    transform-origin: left center;
    transition: transform 1.5s ease-in-out;
}

.gate-overlay.hinge-right img {
    transform-origin: right center;
}

.gate-overlay.animate-open img {
    transform: rotateY(-85deg);
}

.gate-overlay.hinge-right.animate-open img {
    transform: rotateY(85deg);
}

/* Small toggle for flip control */
.flip-control {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Toggle Switch Base Styles */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-400);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

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

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Small toggle variant */
.toggle-switch.small {
    width: 40px;
    height: 20px;
}

.toggle-switch.small .toggle-slider:before {
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
}

.toggle-switch.small input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Preview tabs */
.preview-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.preview-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.preview-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

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

.preview-tab:disabled,
.preview-tab.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.preview-tab svg {
    flex-shrink: 0;
}

.preview-tab-content {
    display: none;
}

.preview-tab-content.active {
    display: block;
}

.preview-image-full {
    position: relative;
    background: var(--bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-image-full img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

.preview-image-full .preview-image-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.status-complete {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: var(--success-color);
}

.status-complete svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    stroke: var(--success-color);
}

.status-complete p {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.status-complete .help-text {
    color: var(--text-muted);
}

.placement-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
}

.placement-control-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.placement-control-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-600);
    text-transform: uppercase;
}

.placement-control-group input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--gray-300);
    border-radius: 3px;
    cursor: pointer;
}

.placement-control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.placement-control-group input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.placement-control-group span {
    font-size: 0.875rem;
    color: var(--gray-700);
    font-weight: 500;
    text-align: center;
}

@media (max-width: 480px) {
    .placement-controls {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Visualize Page Styles
   ============================================ */

/* 3D Gate Container */
.gate-3d-container {
    width: 100%;
    height: 100%;
    min-height: 150px;
}

.gate-3d-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Gate Visualization SVG Styles */
.gate-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.gate-svg .ground {
    fill: #94a3b8;
}

.gate-svg .pillar {
    fill: #64748b;
}

.gate-svg .gate-panel {
    fill: #334155;
}

.gate-svg .barrier-arm {
    fill: #fbbf24;
    stroke: #000;
    stroke-width: 1;
}

.gate-svg .barrier-stripe {
    fill: #000;
}

.gate-svg .barrier-post {
    fill: #64748b;
}

/* Gate handle/detail */
.gate-svg .gate-handle {
    fill: #1e293b;
}

/* Guard hut indicator */
.guard-hut-indicator {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.guard-hut-indicator svg {
    width: 14px;
    height: 14px;
}

/* ============================================
   API Docs Page Styles
   ============================================ */

.api-section h2 {
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--gray-200);
}

.api-endpoint-body h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 1.25rem 0 0.5rem 0;
    color: var(--gray-700);
}

.api-endpoint-body h4:first-child {
    margin-top: 0;
}

.api-endpoint-body p {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.param-table {
    width: 100%;
    font-size: 0.8125rem;
    margin: 0.5rem 0;
}

.param-table th {
    background: var(--gray-100);
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.6875rem;
}

.param-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
}

.param-name {
    font-family: monospace;
    color: var(--primary-color);
}

.param-type {
    color: var(--gray-500);
    font-size: 0.75rem;
}

.param-required {
    color: var(--danger-color);
    font-size: 0.625rem;
    font-weight: 600;
}

.base-url-box {
    background: var(--gray-800);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.base-url-box code {
    color: #10b981;
    font-size: 1rem;
}

.base-url-box .btn {
    flex-shrink: 0;
}

.code-example {
    margin: 1rem 0;
}

.try-it-form {
    display: grid;
    gap: 1rem;
}

.try-it-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 640px) {
    .try-it-row {
        grid-template-columns: 1fr;
    }
}

.response-box {
    background: var(--gray-800);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
    max-height: 300px;
    overflow: auto;
}

.response-box pre {
    color: #e5e7eb;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.8125rem;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

.response-box.success pre {
    color: #10b981;
}

.response-box.error pre {
    color: #f87171;
}

/* ============================================
   Settings Page Styles
   ============================================ */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.settings-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.settings-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.settings-card-header svg {
    width: 24px;
    height: 24px;
    color: var(--primary-color);
}

.settings-card-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.settings-card-body {
    padding: 1.5rem;
}

.api-key-input-wrapper {
    position: relative;
    display: flex;
    gap: 0.5rem;
}

.api-key-input-wrapper .form-input {
    flex: 1;
    font-family: monospace;
    padding-right: 3rem;
}

.toggle-visibility {
    position: absolute;
    right: 110px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 0.5rem;
    display: flex;
}

.toggle-visibility:hover {
    color: var(--gray-600);
}

.api-key-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

.status-icon {
    width: 16px;
    height: 16px;
}

.status-configured {
    color: var(--success-color);
}

.status-not-configured {
    color: var(--gray-400);
}

.connection-status {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--radius);
    display: none;
}

.connection-status.visible {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.connection-status.success {
    background: #dcfce7;
    color: #166534;
}

.connection-status.error {
    background: #fee2e2;
    color: #991b1b;
}

.connection-status.testing {
    background: var(--gray-100);
    color: var(--gray-600);
}

.help-text {
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
}

.help-link {
    color: var(--primary-color);
    text-decoration: none;
}

.help-link:hover {
    text-decoration: underline;
}

.button-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.danger-zone {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}

.danger-zone h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--danger-color);
    margin-bottom: 0.5rem;
}

.danger-zone p {
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-bottom: 1rem;
}
