/* Shared Styles for Kiwrious + iTiles Applications */

* {
    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, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

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

/* Header */
.app-header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

.app-header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.app-header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.back-button {
    display: inline-block;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 20px;
    transition: background 0.3s;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.card h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #dc3545;
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: #28a745;
}

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

/* Buttons */
.button-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

button {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button.secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

button.success {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

button.danger {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

/* Sensor Display */
.sensor-display {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 20px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    margin-bottom: 20px;
}

.sensor-value {
    font-size: 3rem;
    font-weight: bold;
    text-align: center;
    margin: 20px 0;
    color: #4fc3f7;
}

.sensor-label {
    text-align: center;
    font-size: 1.2rem;
    color: #858585;
    margin-bottom: 10px;
}

.sensor-unit {
    font-size: 1.5rem;
    color: #858585;
}

/* Visual Display Area */
.visual-display {
    background: #000;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 20px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.visual-indicator {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    transition: all 0.5s ease;
    box-shadow: 0 0 50px rgba(255, 255, 255, 0.3);
}

/* Tile Grid Visualization */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 20px;
    background: #000;
    border-radius: 12px;
    margin-bottom: 20px;
}

.tile-visual {
    aspect-ratio: 1;
    border-radius: 12px;
    background: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: white;
    transition: all 0.3s ease;
}

/* Info Box */
.info-box {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.info-box strong {
    display: block;
    margin-bottom: 10px;
    color: #856404;
}

.info-box ul {
    margin: 10px 0 0 20px;
    line-height: 1.6;
    color: #856404;
}

/* Log Container */
.log-container {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 15px;
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.log-entry {
    padding: 5px 0;
    border-bottom: 1px solid #333;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry .timestamp {
    color: #858585;
    margin-right: 10px;
}

.log-entry .type-info {
    color: #4fc3f7;
}

.log-entry .type-success {
    color: #81c784;
}

.log-entry .type-error {
    color: #e57373;
}

.log-entry .type-warning {
    color: #ffb74d;
}

/* Stats Display */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-box {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    margin-top: 5px;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    background: #667eea;
    color: white;
}

.badge.success {
    background: #28a745;
}

.badge.warning {
    background: #ffc107;
    color: #333;
}

.badge.danger {
    background: #dc3545;
}

/* Control Group */
.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
}

.control-group input,
.control-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.control-group input:focus,
.control-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* Range Slider */
input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #e0e0e0;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .app-header h1 {
        font-size: 2rem;
    }
    
    .button-group {
        grid-template-columns: 1fr;
    }
    
    .tile-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Loading Spinner */
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Alert */
.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.alert-danger {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}
