/* TR-FMS Professional Dashboard Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Dark Mode Colors (Default) - Modern Industrial */
    --bg-dark: #0d1117;
    --panel-bg: #161b22;
    --panel-header: #21262d;
    --card-bg: #1c2128;
    --border-color: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    /* Accent Colors */
    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-yellow: #d29922;
    --accent-purple: #a371f7;
    --accent-cyan: #39c5cf;

    /* Gradients */
    --gradient-blue: linear-gradient(135deg, #1f6feb 0%, #58a6ff 100%);
    --gradient-green: linear-gradient(135deg, #238636 0%, #3fb950 100%);
    --gradient-header: linear-gradient(180deg, #21262d 0%, #161b22 100%);

    /* Canvas */
    --canvas-bg: #010409;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(88, 166, 255, 0.15);

    /* Dimensions */
    --sidebar-width: 340px;
    --border-radius: 8px;
    --border-radius-sm: 4px;
}

/* Light Mode Theme */
body.light-mode {
    --bg-dark: #f6f8fa;
    --panel-bg: #ffffff;
    --panel-header: #f6f8fa;
    --card-bg: #ffffff;
    --border-color: #d0d7de;
    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-muted: #8c959f;
    --accent-blue: #0969da;
    --accent-green: #1a7f37;
    --accent-red: #cf222e;
    --accent-yellow: #9a6700;
    --canvas-bg: #eaeef2;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --gradient-blue: linear-gradient(135deg, #0969da 0%, #218bff 100%);
    --gradient-header: linear-gradient(180deg, #f6f8fa 0%, #ffffff 100%);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
#app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
#sidebar {
    width: var(--sidebar-width);
    background: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: var(--shadow-lg);
}

/* Logo/Brand Area */
.brand-header {
    background: var(--gradient-header);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: var(--gradient-blue);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    box-shadow: var(--shadow-md);
}

.brand-text {
    flex: 1;
}

.brand-text h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.brand-text span {
    font-size: 11px;
    color: var(--text-muted);
}

.panel-section {
    border-bottom: 1px solid var(--border-color);
}

.panel-header {
    background: var(--panel-header);
    padding: 10px 16px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-content {
    padding: 16px;
}

/* Collapsible Sections */
.collapsible .panel-header {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.collapsible .panel-header:hover {
    background: var(--card-bg);
}

.collapse-icon {
    font-size: 10px;
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.collapsible.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.collapsible.collapsed .collapsible-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* Tabs */
.tabs-section {
    border-bottom: 1px solid var(--border-color);
}

.tabs-header {
    display: flex;
    background: var(--panel-header);
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(88, 166, 255, 0.05);
}

.tab-btn.active {
    color: var(--accent-blue);
    background: var(--panel-bg);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-blue);
}

.tab-content {
    display: none;
}

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

.button-group {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.button-group .btn {
    flex: 1;
}

/* Modern Button Styles */
.btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
    width: 100%;
    margin-bottom: 6px;
    text-align: center;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn.compact {
    padding: 6px 10px;
    font-size: 11px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--gradient-blue);
    border: none;
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1a5fc9 0%, #388bfd 100%);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

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

.btn-secondary:hover {
    background: var(--text-muted);
    border-color: var(--text-muted);
    color: var(--bg-dark);
}

.btn-danger {
    background: linear-gradient(135deg, #b62324 0%, #f85149 100%);
    border: none;
    color: white;
}

.btn-danger:hover {
    filter: brightness(1.1);
}

.btn-warning {
    background: linear-gradient(135deg, #9a6700 0%, #d29922 100%);
    border: none;
    color: white;
}

.btn-warning:hover {
    filter: brightness(1.1);
}

/* Toggle Switches */
.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    transition: background 0.2s;
}

.checkbox-row label:hover {
    background: var(--card-bg);
}

.checkbox-row input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.checkbox-row input[type="checkbox"]:checked {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.checkbox-row input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Form Inputs */
select, input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s;
    margin-bottom: 8px;
}

select:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

select {
    cursor: pointer;
}

/* Robot List */
#robot-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.robot-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
}

.robot-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--text-muted);
    transition: background 0.2s;
}

.robot-card:hover {
    border-color: var(--text-muted);
    transform: translateX(2px);
    box-shadow: var(--shadow-md);
}

.robot-card.selected {
    border-color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.1);
}

.robot-card.selected::before {
    background: var(--accent-blue);
}

.robot-card.status-IDLE::before {
    background: var(--text-muted);
}

.robot-card.status-MOVING::before {
    background: var(--accent-green);
}

.robot-card.status-ERROR::before {
    background: var(--accent-red);
}

.robot-card.status-CHARGING::before {
    background: var(--accent-yellow);
}

.robot-card.mismatch-alarm {
    border-color: var(--accent-red);
    animation: pulse-warning 2s infinite;
}

@keyframes pulse-warning {
    0%, 100% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(248, 81, 73, 0); }
}

.robot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.robot-id {
    font-weight: 600;
    font-size: 14px;
}

.robot-status-text {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--panel-header);
}

.robot-battery {
    height: 6px;
    background: var(--panel-header);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 10px;
}

.battery-level {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Main View */
#main-view {
    flex: 1;
    position: relative;
    background: var(--canvas-bg);
    overflow: hidden;
}

canvas {
    display: block;
    cursor: grab;
}

canvas:active {
    cursor: grabbing;
}

/* Status Bar */
#mqtt-status-bar {
    background: var(--gradient-blue);
    color: white;
    padding: 10px 16px;
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

#mqtt-status-bar.disconnected {
    background: linear-gradient(135deg, #b62324 0%, #f85149 100%);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3fb950;
}

.disconnected .status-dot {
    background: white;
    animation: none;
}

/* Robot Count Badge */
#robot-count-badge {
    background: var(--gradient-blue);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    color: white;
    box-shadow: var(--shadow-sm);
    min-width: 40px;
    text-align: center;
}

/* Legend Styling */
.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 0;
    font-size: 10px;
    color: var(--text-secondary);
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Mismatch Warning */
.mismatch-warning {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--accent-red);
    border-radius: var(--border-radius-sm);
    padding: 8px 10px;
    margin-top: 8px;
    font-size: 10px;
    color: var(--accent-red);
}

/* Animations - removed fadeIn from robot-card to prevent blinking on updates */

/* Responsive Adjustments */
@media (max-width: 1200px) {
    :root {
        --sidebar-width: 300px;
    }
}
