:root {
    /* Coolshrimp Purple Theme */
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --primary-light: #a78bfa;
    --accent: #c084fc;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

/* Dark Mode (Default) */
body[data-theme="dark"] {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-tertiary: #334155;
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border: #475569;
}

/* Light Mode */
body[data-theme="light"] {
    --bg: #ffffff;
    --bg-card: #ffffff;
    --bg-tertiary: #f8fafc;
    --text: #0f172a;
    --text-secondary: #475569;
    --border: #e2e8f0;
}

/* Auto mode - respects system preference */
@media (prefers-color-scheme: light) {
    body[data-theme="auto"] {
        --bg: #ffffff;
        --bg-card: #ffffff;
        --bg-tertiary: #f8fafc;
        --text: #0f172a;
        --text-secondary: #475569;
        --border: #e2e8f0;
    }
}

@media (prefers-color-scheme: dark) {
    body[data-theme="auto"] {
        --bg: #0f172a;
        --bg-card: #1e293b;
        --bg-tertiary: #334155;
        --text: #f1f5f9;
        --text-secondary: #cbd5e1;
        --border: #475569;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg) 0%, #1a1f35 100%);
    color: var(--text);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 20px 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.header-content > div:first-child {
    flex: 1;
    text-align: left;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.theme-switcher button {
    font-size: 1.2rem;
    min-width: 45px;
}

.connection-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid var(--border);
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
    background: #64748b;
    color: white;
}

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

.btn-success:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-2px);
}

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

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

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    transition: all 0.3s ease;
}

.status-indicator .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #64748b;
    animation: pulse 2s infinite;
    transition: background 0.3s ease;
}

.status-indicator .text {
    transition: color 0.3s ease;
}

.status-indicator.connected {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-indicator.connected .dot {
    background: var(--success);
    animation: none;
}

.status-indicator.disconnected {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-indicator.disconnected .dot {
    background: var(--danger);
    animation: pulse 1s infinite;
}

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

.disconnect-banner {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: 2px solid #b91c1c;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    animation: slideDown 0.3s ease;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

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

.disconnect-banner.banner-dismiss {
    animation: slideUp 0.3s ease;
}

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

.banner-content {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.banner-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.banner-text {
    flex: 1;
    min-width: 200px;
}

.banner-text strong {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 6px;
    color: white;
}

.banner-text p {
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
}

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

.banner-actions .btn {
    padding: 10px 20px;
    font-size: 0.9rem;
}

.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 24px;
    min-width: 250px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 2000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

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

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

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

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

.device-info {
    margin-bottom: 30px;
}

.device-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 30px;
}

.device-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.device-icon {
    font-size: 4rem;
}

.device-card h2 {
    margin-bottom: 8px;
}

.device-desc {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.device-meta {
    display: flex;
    gap: 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

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

.interface-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
}

.interface-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: -30px -30px 20px -30px;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.interface-header h3 {
    margin: 0;
    color: var(--text);
}

.interface-panel h3 {
    margin-bottom: 20px;
    color: var(--text);
}

.flash-controls {
    display: grid;
    gap: 20px;
    margin-bottom: 24px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    color: var(--text);
    font-weight: 500;
}

.control-group input[type="file"],
.control-group select {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
}

.control-group input[type="file"] {
    cursor: pointer;
}

.help-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.progress-bar {
    width: 100%;
    height: 40px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success) 0%, #34d399 100%);
    width: 0%;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

#progressText {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.terminal {
    background: #000;
    border-radius: 8px;
    padding: 20px;
    font-family: 'Courier New', monospace;
    color: #0f0;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 20px;
}

.terminal-line {
    margin: 4px 0;
    line-height: 1.5;
}

.terminal-error {
    color: #ef4444;
}

.terminal-success {
    color: #10b981;
}

.terminal-warning {
    color: #f59e0b;
}

.info-box {
    background: var(--bg-tertiary);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.info-box h4 {
    margin-bottom: 12px;
    color: var(--text);
}

.info-box ul {
    list-style: none;
    padding-left: 0;
}

.info-box li {
    padding: 6px 0;
    color: var(--text-secondary);
}

.info-box li::before {
    content: "→ ";
    color: var(--primary);
    font-weight: bold;
    margin-right: 8px;
}

.info-box a {
    color: var(--primary);
    text-decoration: none;
}

.info-box a:hover {
    text-decoration: underline;
}

/* Programmer Interface */
.prog-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.prog-file {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.file-btn {
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.prog-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.prog-actions .btn {
    flex: 1;
    min-width: 120px;
}

.compare-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.compare-controls .file-btn {
    margin: 0;
}

.compare-controls span {
    flex: 1;
    min-width: 150px;
    color: var(--text-secondary);
    font-style: italic;
}

.prog-info-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.info-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.info-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.info-table td:first-child {
    width: 150px;
    color: var(--text-secondary);
}

.terminal {
    background: #000;
    color: #0f0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    padding: 15px;
    border-radius: 6px;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.6;
}

.term-line {
    margin: 4px 0;
}

.term-warn {
    color: #f59e0b;
}

.term-err {
    color: #ef4444;
}

.term-ok {
    color: #10b981;
}

/* Hex Editor */
.hex-file-load {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.hex-file-load .file-btn {
    margin: 0;
}

#hexFileLoaded {
    flex: 1;
    color: var(--text-secondary);
    font-style: italic;
}

.hex-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.hex-info {
    margin-left: auto;
    color: var(--text-secondary);
}

.hex-container {
    display: grid;
    grid-template-columns: 100px 1fr 200px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    max-height: 600px;
    overflow-y: auto;
}

.hex-address, .hex-data, .hex-ascii {
    border-right: 1px solid var(--border);
}

.hex-ascii {
    border-right: none;
}

.hex-header {
    background: var(--primary);
    color: white;
    padding: 10px;
    font-weight: 600;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

#hexAddresses, #hexBytes, #hexAscii {
    padding: 10px;
}

.hex-row {
    display: flex;
    padding: 2px 0;
}

.hex-byte {
    display: inline-block;
    width: 24px;
    cursor: pointer;
    padding: 2px;
}

.hex-byte:hover {
    background: var(--primary);
    color: white;
}

.hex-byte.edited {
    background: #f59e0b;
    color: white;
}

.hex-char {
    display: inline-block;
    width: 10px;
    cursor: pointer;
}

.console-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0;
    margin-bottom: 30px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.console-header h3 {
    margin: 0;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.console-controls {
    display: flex;
    gap: 20px;
    padding: 20px 30px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    align-items: center;
}

.console-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    flex: 1;
}

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

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
}

.console-output {
    background: #000;
    color: #0f0;
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 0.95rem;
    padding: 20px;
    flex: none;
    height: 320px;         
    min-height: 200px;
    max-height: 70vh;      
    overflow-y: auto;
  
}

.console-output { cursor: ns-resize; }

.console-output:active {
    cursor: grabbing;   
}

.console-resize-handle{
  height: 14px;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.05);
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

/* little “grip dots” */
.console-resize-handle::before{
  content: "⋯";
  letter-spacing: 6px;
  color: rgba(255,255,255,.35);
  font-size: 18px;
  line-height: 0;
}


.console-line {
    margin: 4px 0;
    overflow-wrap: normal;
    word-break: normal;
    white-space: pre-wrap;
    padding: 2px 0;
}

.console-line.console-send {
    color: #60a5fa;
}

.console-line.console-error {
    color: #ef4444;
}

.console-line.console-warning {
    color: #f59e0b;
}

.console-line.console-info {
    color: #94a3b8;
}

.console-line.console-success {
    color: #10b981;
}

.console-line .timestamp {
    color: #64748b;
    margin-right: 8px;
}

.console-input-area {
    padding: 20px 30px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.console-input-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

#consoleInput {
    flex: 1;
    min-width: 200px;
    padding: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 0.95rem;
}

#consoleInput:focus {
    outline: none;
    border-color: var(--primary);
}

#consoleInput:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quick-commands-panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.quick-commands-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.btn-close-quick {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close-quick:hover {
    opacity: 0.8;
}

.quick-commands-content {
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
}

.quick-cmd-btn {
    padding: 10px 15px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.quick-cmd-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

.quick-cmd-btn .cmd-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 4px;
}

.quick-cmd-btn:hover .cmd-label {
    color: rgba(255, 255, 255, 0.8);
}

.quick-title{
  margin: 10px 0 6px;
  color: rgba(255,255,255,.7);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.quick-btn{
  margin: 4px 6px 0 0;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: #fff;
  cursor: pointer;
}

.quick-btn:hover{
  border-color: rgba(255,255,255,.22);
  transform: translateY(-1px);
}

.quick-cmd-btn.danger{
  border-color: rgba(239,68,68,.45);
  background: rgba(239,68,68,.12);
}

.quick-cmd-btn.danger:hover{
  border-color: rgba(239,68,68,.65);
  transform: translateY(-1px);
}


.console-input-options {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.console-output::-webkit-scrollbar {
    width: 8px;
}

.console-output::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.console-output::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

.console-output::-webkit-scrollbar-thumb:hover {
    background: #444;
}

footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

footer a {
    color: var(--primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .header-content {
        flex-direction: column;
        align-items: center;
    }
    
    .header-content > div:first-child {
        text-align: center;
    }
    
    .header-controls {
        width: 100%;
        justify-content: center;
    }
    
    .connection-panel {
        flex-direction: column;
        gap: 16px;
    }
    
    .device-header {
        flex-direction: column;
        text-align: center;
    }
    
    .device-actions {
        flex-direction: column;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    
    .console-panel {
        min-height: 400px;
    }
    
    .console-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .console-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .console-buttons .btn {
        width: 100%;
    }
    
    .console-input-row {
        flex-direction: column;
    }
    
    .console-input-row .btn {
        width: 100%;
    }
    
    #consoleInput {
        width: 100%;
    }
    
    .flash-controls {
        gap: 15px;
    }
    
    .interface-header {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .quick-commands-content {
        grid-template-columns: 1fr;
    }
}

/* Tablet responsive */
@media (max-width: 1024px) and (min-width: 769px) {
    .device-grid-page {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .quick-commands-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Large screens - optimize space */
@media (min-width: 1400px) {
    .container {
        max-width: 1200px;
    }
    
    .device-grid-page {
        grid-template-columns: repeat(3, 1fr);
    }
}
    
    .device-header {
        flex-direction: column;
        text-align: center;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }
}
