/* Grundinställningar */
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; padding: 0; background-color: #f4f4f9; color: #333; }
.login-container { max-width: 400px; margin: 150px auto; background: white; padding: 40px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.08); text-align: center; }
.login-container input { width: 90%; padding: 14px; margin: 15px 0; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 16px; background-color: #fafafa; transition: border-color 0.3s, box-shadow 0.3s; }
.login-container input:focus { border-color: #888; background-color: #fff; box-shadow: 0 0 0 3px rgba(136,136,136,0.1); outline: none; }
.login-container button { width: 100%; padding: 14px; background-color: #555; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 16px; font-weight: bold; transition: background-color 0.3s, transform 0.1s; box-shadow: 0 4px 10px rgba(85,85,85,0.2); }
.login-container button:hover { background-color: #333; transform: translateY(-1px); box-shadow: 0 6px 15px rgba(51,51,51,0.3); }
.hub-container { text-align: center; margin-top: 100px; }
.hub-title { font-size: 36px; color: #444; margin-bottom: 40px; font-weight: 800; }
.hub-cards { display: flex; justify-content: center; gap: 40px; margin-top: 20px; }
.card { background: #555; color: white; text-decoration: none; padding: 50px 80px; font-size: 28px; border-radius: 16px; transition: transform 0.2s, background 0.3s, box-shadow 0.2s; box-shadow: 0 8px 20px rgba(0,0,0,0.12); font-weight: bold; border: 1px solid rgba(255,255,255,0.1); }
.card:hover { transform: translateY(-5px); background: #333; box-shadow: 0 15px 30px rgba(0,0,0,0.2); }
.logout-link { display: inline-block; margin-top: 60px; color: #d9534f; text-decoration: none; font-weight: bold; font-size: 18px; transition: color 0.2s; }
.logout-link:hover { color: #c9302c; }

/* --- SIDOMENY OCH LAYOUT --- */
.app-wrapper { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 260px; min-width: 80px; background-color: #2c2c2c; color: #fff; display: flex; flex-direction: column; box-shadow: 4px 0 15px rgba(0,0,0,0.08); z-index: 10; transition: width 0.3s ease; }
.sidebar-header { padding: 30px 20px; background-color: #1a1a1a; font-size: 22px; font-weight: bold; display: flex; align-items: center; justify-content: space-between; letter-spacing: 2px; border-bottom: 1px solid #333; white-space: nowrap; overflow: hidden; }
.sidebar-menu { flex: 1; list-style: none; padding: 15px 0; margin: 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-menu li a { display: flex; align-items: center; padding: 16px 20px; margin: 0 10px 5px 10px; color: #bbb; text-decoration: none; font-size: 16px; border-radius: 8px; transition: all 0.2s ease; white-space: nowrap; }
.sidebar-menu li a:hover, .sidebar-menu li a.active { background-color: #3d3d3d; color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.sidebar-footer { padding: 20px; background-color: #1a1a1a; border-top: 1px solid #333; overflow: hidden; white-space: nowrap; }
.sidebar-footer a { color: #d9534f; text-decoration: none; font-weight: bold; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; transition: background 0.2s; }
.sidebar-footer a:hover { background: rgba(217, 83, 79, 0.1); }
.main-content { flex: 1; background-color: #f4f4f9; padding: 40px; overflow-y: auto; position: relative; }

/* Dra för att ändra storlek */
.resizer { width: 5px; background: transparent; cursor: col-resize; z-index: 20; transition: background 0.2s; }
.resizer:hover, .resizer.resizing { background: #555; }

/* Infälld Meny (Collapsed) */
.sidebar.collapsed { width: 80px !important; }
.sidebar.collapsed .logo-text, .sidebar.collapsed .menu-text { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 30px 0; }
.sidebar.collapsed .sidebar-menu li a { justify-content: center; padding: 16px 0; margin: 0 10px 5px 10px; }
.sidebar.collapsed .sidebar-footer a { justify-content: center; }
.sidebar.collapsed .menu-icon { margin-right: 0; font-size: 22px; }

.toggle-btn { background: none; border: none; color: white; font-size: 24px; cursor: pointer; padding: 0 5px; }
.menu-icon { margin-right: 15px; font-size: 18px; transition: margin 0.3s; }

/* --- KAMERA-MODUL --- */
.camera-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 25px; }
.camera-card { background: #2c2c2c; border-radius: 12px; overflow: hidden; position: relative; cursor: pointer; border: 1px solid #3d3d3d; transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 6px 15px rgba(0,0,0,0.15); }
.camera-card:hover { transform: translateY(-4px); box-shadow: 0 12px 25px rgba(0,0,0,0.25); border-color: #555; }
.camera-header { background: #1a1a1a; color: white; padding: 14px; font-weight: bold; letter-spacing: 1px; border-bottom: 1px solid #333; }
.camera-feed { position: relative; width: 100%; padding-top: 56.25%; background: #000; }
.video-frame { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }
.click-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; }
.placeholder-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #888; text-align: center; font-family: monospace; }
.icon-indicator { position: absolute; top: 12px; right: 12px; font-size: 20px; background: rgba(0,0,0,0.6); padding: 8px; border-radius: 50%; backdrop-filter: blur(4px); }

.settings-fab { position: fixed; bottom: 35px; left: 295px; background-color: #555; color: white; border: none; border-radius: 50%; width: 65px; height: 65px; font-size: 30px; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,0.3); transition: transform 0.2s, background 0.3s, left 0.3s; z-index: 500; display: flex; align-items: center; justify-content: center; }
.settings-fab:hover { background-color: #333; transform: scale(1.05); }
.sidebar.collapsed ~ .main-content .settings-fab { left: 115px; } /* Flyttar kugghjulet när menyn krymper */

.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.85); backdrop-filter: blur(5px); }
.modal-content { background-color: #2c2c2c; margin: 3% auto; padding: 25px; border: 1px solid #444; width: 90%; max-width: 1400px; max-height: 85vh; overflow-y: auto; border-radius: 16px; color: white; box-shadow: 0 15px 40px rgba(0,0,0,0.6); }
.close-btn { background: #d9534f; color: white; padding: 10px 20px; float: right; font-size: 16px; font-weight: bold; border-radius: 8px; cursor: pointer; border: none; transition: background 0.2s; }
.close-btn:hover { background: #c9302c; }
.modal-video-container { position: relative; width: 100%; padding-top: 56.25%; background: #000; margin-bottom: 20px; border-radius: 8px; overflow: hidden; box-shadow: inset 0 0 20px rgba(0,0,0,0.5); }
.large-video-frame { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }
.controls-panel { display: flex; gap: 15px; justify-content: center; margin-top: 20px; }
.control-btn { padding: 15px 35px; font-size: 18px; font-weight: bold; border: none; border-radius: 8px; cursor: pointer; transition: transform 0.1s, opacity 0.2s; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.control-btn:hover { opacity: 0.9; transform: translateY(-2px); }
.control-btn:active { transform: translateY(0); }
.control-btn.listen { background: #555; color: white; }
.control-btn.talk { background: #d9534f; color: white; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; margin-top: 25px; }
.camera-settings-card { background: #1a1a1a; padding: 30px; border-radius: 12px; color: white; border: 1px solid #333; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.camera-settings-card h3 { color: #fff; margin-top: 0; border-bottom: 1px solid #333; padding-bottom: 15px; font-size: 20px; }
.row { display: flex; gap: 20px; margin-bottom: 15px; }
.col { flex: 1; }
.camera-settings-card label { display: block; color: #bbb; font-weight: bold; margin-bottom: 8px; font-size: 14px; }
.camera-settings-card input, .camera-settings-card select { width: 100%; padding: 14px; background: #2c2c2c; border: 1px solid #444; color: white; border-radius: 8px; box-sizing: border-box; transition: border-color 0.3s, background 0.3s; }
.camera-settings-card input:focus, .camera-settings-card select:focus { border-color: #888; background: #333; outline: none; }
.save-btn { background-color: #555; color: white; padding: 16px 20px; border: none; border-radius: 8px; cursor: pointer; font-size: 16px; font-weight: bold; width: 100%; margin-top: 20px; transition: background 0.3s, transform 0.1s; box-shadow: 0 4px 10px rgba(0,0,0,0.3);}
.save-btn:hover { background-color: #444; transform: translateY(-1px); }

/* --- ROBOT-MODUL --- */
.robot-layout { display: flex; gap: 25px; height: calc(100vh - 120px); }
.robot-video-section { flex: 2; background: #2c2c2c; border-radius: 16px; padding: 25px; display: flex; flex-direction: column; box-shadow: 0 8px 25px rgba(0,0,0,0.15); border: 1px solid #3d3d3d; }
.robot-controls-section { flex: 1; background: #2c2c2c; border-radius: 16px; padding: 25px; color: white; overflow-y: auto; box-shadow: 0 8px 25px rgba(0,0,0,0.15); border: 1px solid #3d3d3d; }
.robot-feed { flex: 1; background: black; border-radius: 8px; display: flex; align-items: center; justify-content: center; position: relative; border: 1px solid #111; overflow: hidden; box-shadow: inset 0 0 30px rgba(0,0,0,0.8); }
.d-pad { display: grid; grid-template-columns: repeat(3, 75px); grid-template-rows: repeat(3, 75px); gap: 12px; justify-content: center; margin: 35px 0; }
.d-btn { background: #444; color: white; border: none; border-radius: 12px; font-size: 28px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.1s, transform 0.1s; box-shadow: 0 4px 10px rgba(0,0,0,0.3); border: 1px solid #555; }
.d-btn:active { background: #666; transform: scale(0.92); box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.d-up { grid-column: 2; grid-row: 1; }
.d-left { grid-column: 1; grid-row: 2; }
.d-home { grid-column: 2; grid-row: 2; background: #d9534f; font-size: 16px; font-weight: bold; border-color: #c9302c; }
.d-home:active { background: #c9302c; }
.d-right { grid-column: 3; grid-row: 2; }
.d-down { grid-column: 2; grid-row: 3; }
.robot-slider-group { margin-bottom: 30px; }
.robot-slider-group label { display: block; font-weight: bold; margin-bottom: 12px; color: #ccc; font-size: 14px; }
.robot-slider { width: 100%; cursor: pointer; accent-color: #555; }
.ai-tracking-box { background: #1a1a1a; padding: 25px; border-radius: 12px; text-align: center; border: 1px solid #333; margin-bottom: 25px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
.ai-toggle-btn { padding: 14px 25px; font-size: 18px; font-weight: bold; border-radius: 8px; cursor: pointer; border: none; transition: all 0.3s; background: #444; color: white; width: 100%; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.ai-toggle-btn.active { background: #5cb85c; box-shadow: 0 4px 15px rgba(92, 184, 92, 0.3); }

/* ========================================= */
/* RESPONSIV MOBILANPASSNING                 */
/* ========================================= */
.mobile-header { display: none; background: #1a1a1a; color: white; padding: 15px 20px; align-items: center; justify-content: space-between; box-shadow: 0 4px 10px rgba(0,0,0,0.1); border-bottom: 1px solid #333; }
.mobile-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 900; backdrop-filter: blur(2px); }

@media (max-width: 768px) {
    .app-wrapper { flex-direction: column; display: block; overflow-y: auto; }
    
    /* Gömmer och stylar om menyn för mobil */
    .sidebar { position: fixed; left: -300px; top: 0; height: 100vh; width: 260px !important; z-index: 1000; transition: left 0.3s ease; }
    .sidebar.mobile-open { left: 0; }
    .mobile-overlay.mobile-open { display: block; }
    .sidebar-header .toggle-btn { display: none; } /* Dölj infällningsknapp på mobil */
    .resizer { display: none; } /* Stäng av dra-funktionen på mobil */
    
    .mobile-header { display: flex; }
    .main-content { padding: 15px; overflow-y: visible; height: auto; }
    
    /* Justerar gridden för små skärmar (1 kolumn istället för 2) */
    .camera-grid, .settings-grid { grid-template-columns: 1fr; }
    .robot-layout { flex-direction: column; height: auto; }
    .hub-cards { flex-direction: column; align-items: center; }
    .card { width: 80%; text-align: center; }
    .row { flex-direction: column; gap: 5px; }
    
    /* Flyttar inställningsknappen för mobil */
    .settings-fab { left: auto; right: 20px; bottom: 20px; width: 55px; height: 55px; font-size: 24px; }
    .sidebar.collapsed ~ .main-content .settings-fab { left: auto; }
}