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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    min-height: 100vh;
    color: #ffffff;
    overflow-x: hidden;
}

.container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.panel {
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    max-width: 420px;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

.panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
}

.panel-header {
    text-align: center;
    margin-bottom: 30px;
}

.panel-header h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
}

.region-selector {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
}

.region-btn {
    flex: 1;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.region-btn.active {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.region-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.tab-container {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 30px;
    gap: 4px;
}

.tab {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.8);
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.input-group {
    margin-bottom: 24px;
}

.input-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.9);
}

.button-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

textarea, input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

textarea:focus, input[type="text"]:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
    background: rgba(255, 255, 255, 0.08);
}

textarea::placeholder, input[type="text"]::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.select-input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.select-input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.select-input option {
    background: #1a1a2e;
    color: white;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: translateY(-1px);
}

.btn-start {
    width: 100%;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 16px;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.3);
}

.btn-start:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4);
}

.btn-auto {
    width: 100%;
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    padding: 16px;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.3);
}

.btn-auto:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(33, 150, 243, 0.4);
}

.btn-auto.active {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    box-shadow: 0 6px 20px rgba(244, 67, 54, 0.3);
}

.btn-auto.active:hover {
    box-shadow: 0 8px 25px rgba(244, 67, 54, 0.4);
}

.btn-connect {
    width: 100%;
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
    padding: 16px;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.3);
    margin-bottom: 12px;
}

.btn-connect:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 152, 0, 0.4);
}

.btn-disconnect {
    width: 100%;
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: white;
    padding: 16px;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(244, 67, 54, 0.3);
    margin-bottom: 12px;
}

.btn-disconnect:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(244, 67, 54, 0.4);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-small {
    padding: 8px 12px;
    font-size: 12px;
}

.icon {
    font-size: 16px;
}

.status-text {
    margin-top: 8px;
    font-size: 12px;
    color: #4CAF50;
    font-weight: 500;
}

.status-text.empty {
    color: rgba(255, 255, 255, 0.4);
}

.status-text.connected {
    color: #4CAF50;
    font-weight: 600;
}

.status-text.connecting {
    color: #FF9800;
    font-weight: 600;
}

.connection-controls {
    margin-bottom: 20px;
}

.connection-status {
    text-align: center;
    margin-bottom: 20px;
}

.progress-container {
    margin-top: 24px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    border-radius: 4px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    font-size: 18px;
    font-weight: 700;
    color: #4CAF50;
    margin-bottom: 8px;
}

.progress-status {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.saved-profiles {
    margin-bottom: 20px;
}

.saved-profiles-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.saved-profiles-header span {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.profiles-list {
    max-height: 120px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px;
}

.profiles-list::-webkit-scrollbar {
    width: 6px;
}

.profiles-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.profiles-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.profiles-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.empty-state {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    padding: 20px;
}

.profile-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.2s ease;
}

.profile-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.profile-item:last-child {
    margin-bottom: 0;
}

.remove-btn {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.remove-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.status-display {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    min-height: 80px;
    max-height: 120px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    line-height: 1.4;
}

.status-display::-webkit-scrollbar {
    width: 6px;
}

.status-display::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.status-display::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* WebSocket Log Styles */
.websocket-log {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    font-size: 12px;
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', Monaco, monospace;
    line-height: 1.4;
    margin-bottom: 12px;
}

.websocket-log::-webkit-scrollbar {
    width: 8px;
}

.websocket-log::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.websocket-log::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.websocket-log::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.log-placeholder {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
    padding: 40px 20px;
}

.log-entry {
    padding: 4px 0;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.log-info {
    color: rgba(255, 255, 255, 0.8);
}

.log-success {
    color: #4CAF50;
    font-weight: 500;
}

.log-error {
    color: #f44336;
    font-weight: 500;
}

.log-receive {
    color: #2196F3;
    font-weight: 500;
}

.log-send {
    color: #FF9800;
    font-weight: 500;
}

.log-data {
    color: rgba(255, 255, 255, 0.6);
    margin-left: 20px;
    font-size: 11px;
}

.log-controls {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.log-controls .btn-secondary.active {
    background: rgba(76, 175, 80, 0.2);
    border-color: #4CAF50;
    color: #4CAF50;
}

.panel-footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
}

.notification-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    pointer-events: none;
    width: 100%;
    max-width: 400px;
    padding: 0 20px;
}

.notification {
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transform: translateY(-100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    position: relative;
    overflow: hidden;
}

.notification::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #4CAF50, #45a049);
}

.notification.success::before {
    background: linear-gradient(90deg, #4CAF50, #45a049);
}

.notification.error::before {
    background: linear-gradient(90deg, #f44336, #d32f2f);
}

.notification.info::before {
    background: linear-gradient(90deg, #2196F3, #1976D2);
}

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

/* Responsive Design */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .panel {
        padding: 20px;
        border-radius: 16px;
    }
    
    .panel-header h1 {
        font-size: 20px;
    }
    
    .button-row {
        flex-direction: column;
        gap: 8px;
    }
    
    .button-row .btn {
        width: 100%;
    }

    .tab-container {
        flex-direction: column;
    }

    .tab {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .websocket-log {
        min-height: 150px;
        max-height: 250px;
    }
}

/* Loading Animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 2s infinite;
}

/* Success Animation */
@keyframes success {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.success-animation {
    animation: success 0.6s ease-in-out;
}
