@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&family=Source+Code+Pro:wght@400;600&display=swap');

/* ==================== CSS Variables ==================== */
:root {
    /* Professional color palette - refined navy & emerald (from user snippet) */
    --bg-primary: #0f1419;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2128;
    --border-primary: #2d333b;
    --border-accent: #3fb950;
    --text-primary: #e6edf3;
    --text-secondary: #7d8590;
    --text-tertiary: #484f58;
    --accent-primary: #3fb950;
    --accent-secondary: #2ea043;
    /* Adjusted slightly */
    --accent-warning: #f0883e;
    --accent-error: #f85149;
    --surface-glass: rgba(22, 27, 34, 0.8);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --border-radius: 12px;
    --transition-fast: 0.2s ease;
    --transition-medium: 0.3s ease;
}

/* ==================== Reset & Base ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Lexend', -apple-system, system-ui, sans-serif;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 50%, #0d1117 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
    padding: 20px;
}

svg {
    transition: all 0.2s ease;
}

/* Subtle grid background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(var(--border-primary) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-primary) 1px, transparent 1px);
    background-size: 64px 64px;
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

/* Gradient accent overlay */
body::after {
    content: '';
    position: fixed;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(63, 185, 80, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ==================== App Container ==================== */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1000px;
    margin: 0 auto;
}

/* ==================== Header ==================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    animation: fadeSlideDown 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

.header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    background: var(--bg-tertiary);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-primary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-tertiary);
    box-shadow: 0 0 0 2px rgba(125, 133, 144, 0.15);
    transition: var(--transition-fast);
}

.status-dot.disconnected {
    background: var(--accent-error);
    box-shadow: 0 0 0 2px rgba(248, 81, 73, 0.2);
}

.status-dot.connected {
    background: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(63, 185, 80, 0.2);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* ==================== Connection Panel ==================== */
.connection-panel {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
    justify-content: center;
    animation: fadeSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 8px;
    font-family: 'Lexend', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    letter-spacing: 0.01em;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

.btn-primary,
.btn-success {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled),
.btn-success:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent-secondary);
    /* Blueish from snippet */
    background: rgba(88, 166, 255, 0.05);
}

/* ==================== Button Grid ==================== */
.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
    animation: fadeSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.button-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius);
    padding: 24px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.button-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.button-card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.button-card:hover::before {
    opacity: 1;
}

.button-number {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-primary);
    font-family: 'Source Code Pro', monospace;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.button-action {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
    min-height: 24px;
    font-weight: 500;
}

.btn-edit {
    padding: 8px 20px;
    background: transparent;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition-fast);
    font-family: 'Lexend', sans-serif;
}

.btn-edit:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(63, 185, 80, 0.05);
}

/* ==================== Action Bar ==================== */
.action-bar {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding: 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
    border-radius: var(--border-radius);
    margin-top: 40px;
}

/* ==================== Modal ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 17, 23, 0.85);
    /* Darker backdrop */
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-primary);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 24px;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* ==================== Form Elements ==================== */
.form-group {
    margin-bottom: 24px;
}

.form-group.hidden {
    display: none;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group select,
.form-group input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Lexend', sans-serif;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.form-group select:focus,
.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.15);
}

/* Custom Checkboxes */
.modifier-checkboxes {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.9rem;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 14px 28px;
    color: var(--text-primary);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2000;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.toast.success {
    border-left: 4px solid var(--accent-primary);
}

.toast.error {
    border-left: 4px solid var(--accent-error);
}