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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --online-color: #10b981;
    --offline-color: #94a3b8;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.hidden {
    display: none !important;
}

/* Login Screen */
#loginScreen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
}

.error-message {
    color: var(--error-color);
    margin-top: 0.5rem;
    font-size: 0.875rem;
    min-height: 1.25rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

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

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

.btn-secondary:hover {
    background-color: #475569;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Dashboard */
.dashboard-header {
    background: var(--card-bg);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
    min-width: 44px;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-toggle-btn:hover {
    background-color: var(--bg-color);
}

.sidebar-toggle-btn:active {
    background-color: var(--border-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.dashboard-main {
    display: flex;
    height: calc(100vh - 60px);
    position: relative;
    transition: margin-right 0.3s ease;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar.mobile-hidden {
    transform: translateX(-100%);
}

.sidebar-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.client-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.client-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.client-item:hover {
    background-color: var(--bg-color);
    border-color: var(--primary-color);
}

.client-item.selected {
    background-color: #eff6ff;
    border-color: var(--primary-color);
}

.client-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.client-id {
    font-weight: 600;
    color: var(--text-primary);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-online {
    background-color: #d1fae5;
    color: #065f46;
}

.status-offline {
    background-color: #f1f5f9;
    color: #475569;
}

.client-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    font-style: italic;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    transition: margin-right 0.3s ease;
}

.panel {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel-header h2 {
    font-size: 1.25rem;
}

.client-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    margin-bottom: -2px;
}

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

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

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

/* Result Box */
.result-box {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 400px;
    overflow-y: auto;
}

.result-box.success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.result-box.error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.result-box.info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

/* History List */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.history-item-type {
    font-weight: 600;
    color: var(--primary-color);
}

.history-item-time {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.history-item-details {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Response Panel Toggle Button */
.response-panel-toggle {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.response-panel-toggle:hover {
    background: var(--primary-hover);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.response-panel-toggle.hidden {
    display: none;
}

/* Response Panel */
.response-panel {
    position: fixed;
    top: 60px;
    right: 0;
    width: 400px;
    height: calc(100vh - 60px);
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 999;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
}

.response-panel.open {
    transform: translateX(0);
}

.dashboard-main.response-panel-open {
    margin-right: 400px;
}

.response-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.response-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.response-close-btn {
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
    line-height: 1;
    min-width: auto;
}

.response-header h3 {
    font-size: 1rem;
}

.response-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}

.response-item {
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 6px;
    font-size: 0.875rem;
    border-left: 3px solid var(--primary-color);
}

.response-item.error {
    border-left-color: var(--error-color);
}

.response-item.success {
    border-left-color: var(--success-color);
}

.response-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.response-item-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.response-item-content {
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    word-break: break-all;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

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

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

/* Mobile Responsive Styles */
@media (max-width: 1024px) {
    .dashboard-main.response-panel-open {
        margin-right: 0;
    }
    
    .response-panel {
        width: 100%;
        max-width: 100%;
    }
    
    /* Ensure response panel is above sidebar on mobile */
    .response-panel {
        z-index: 1001;
    }
    
    .sidebar {
        z-index: 998;
    }
}

@media (max-width: 768px) {
    /* Dashboard Header */
    .dashboard-header {
        padding: 1rem;
        flex-wrap: wrap;
    }
    
    .header-left {
        flex: 1;
        min-width: 0;
    }
    
    .sidebar-toggle-btn {
        display: block;
    }
    
    .dashboard-header h1 {
        font-size: 1.25rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .header-actions {
        flex-shrink: 0;
    }
    
    /* Dashboard Main */
    .dashboard-main {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 60px);
        position: relative;
    }
    
    /* Sidebar */
    .sidebar {
        position: fixed;
        top: 60px;
        left: 0;
        width: 280px;
        max-width: 85vw;
        height: calc(100vh - 60px);
        border-right: 1px solid var(--border-color);
        border-bottom: none;
        padding: 1rem;
        z-index: 998;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 997;
    }
    
    .sidebar-overlay.active {
        display: block;
        animation: fadeIn 0.3s ease;
    }
    
    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }
    
    .sidebar-section h2 {
        font-size: 1.1rem;
    }
    
    /* Content Area */
    .content-area {
        padding: 1rem;
    }
    
    .panel {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .panel-header h2 {
        font-size: 1.1rem;
    }
    
    /* Tabs */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .tabs::-webkit-scrollbar {
        display: none;
    }
    
    .tab-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    /* Buttons */
    .btn {
        padding: 0.875rem 1.25rem;
        font-size: 0.95rem;
        min-height: 44px; /* Touch-friendly size */
    }
    
    .btn-small {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        min-height: 36px;
    }
    
    /* Form Elements */
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 0.875rem;
        font-size: 1rem; /* Prevents zoom on iOS */
    }
    
    /* Result Box */
    .result-box {
        padding: 0.875rem;
        font-size: 0.8rem;
        max-height: 300px;
    }
    
    /* Client Items */
    .client-item {
        padding: 0.875rem;
    }
    
    .client-item-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    /* Response Panel Toggle */
    .response-panel-toggle {
        width: 56px;
        height: 56px;
        right: 15px;
        bottom: 20px;
        top: auto;
        transform: none;
        font-size: 1.75rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        -webkit-tap-highlight-color: transparent;
    }
    
    .response-panel-toggle:active {
        transform: scale(0.95);
    }
    
    /* Response Panel */
    .response-panel {
        width: 100%;
        top: 0;
        height: 100vh;
        z-index: 1001;
        box-shadow: -4px 0 16px rgba(0, 0, 0, 0.2);
    }
    
    .response-header {
        padding: 1rem;
    }
    
    .response-header h3 {
        font-size: 0.95rem;
    }
    
    .response-list {
        padding: 0.875rem;
    }
    
    .response-item {
        padding: 0.875rem;
        font-size: 0.85rem;
    }
    
    .response-item-content {
        font-size: 0.7rem;
    }
    
    /* History Items */
    .history-item {
        padding: 0.875rem;
    }
    
    .history-item-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    /* Login Screen */
    .login-container {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .login-container h1 {
        font-size: 1.5rem;
        margin-bottom: 1.25rem;
    }
}

@media (max-width: 480px) {
    /* Extra small devices */
    .dashboard-header {
        padding: 0.75rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .header-left {
        width: 100%;
    }
    
    .dashboard-header h1 {
        font-size: 1.1rem;
    }
    
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .content-area {
        padding: 0.75rem;
    }
    
    .panel {
        padding: 0.875rem;
    }
    
    .tab-btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.85rem;
    }
    
    .btn {
        width: 100%;
        padding: 1rem;
    }
    
    .response-panel-toggle {
        width: 50px;
        height: 50px;
        right: 10px;
        bottom: 15px;
        font-size: 1.5rem;
    }
    
    /* Prevent text selection on mobile for better UX */
    .client-item,
    .tab-btn,
    .btn {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    .sidebar {
        padding: 0.875rem;
    }
    
    .client-item {
        padding: 0.75rem;
    }
    
    .response-item {
        padding: 0.75rem;
    }
    
    .login-container {
        padding: 1.25rem;
    }
}

/* Tablet specific adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 250px;
    }
    
    .response-panel {
        width: 350px;
    }
    
    .dashboard-main.response-panel-open {
        margin-right: 350px;
    }
    
    .content-area {
        padding: 1.5rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .client-item:hover {
        background-color: transparent;
        border-color: var(--border-color);
    }
    
    .tab-btn:hover {
        color: var(--text-secondary);
    }
    
    .btn-primary:hover,
    .btn-secondary:hover {
        opacity: 0.9;
    }
    
    /* Increase tap targets */
    .client-item {
        min-height: 48px;
    }
    
    .tab-btn {
        min-height: 44px;
    }
    
    /* Better touch feedback */
    .client-item:active {
        background-color: var(--bg-color);
        transform: scale(0.98);
    }
    
    .btn:active {
        transform: scale(0.97);
    }
    
    .tab-btn:active {
        opacity: 0.7;
    }
}

/* Prevent horizontal scroll on mobile */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }
    
    .dashboard-main {
        overflow-x: hidden;
    }
    
    .content-area {
        overflow-x: hidden;
    }
}
