/* === PAINEL DE CONTROLE MODERNO === */

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

:root {
    --primary-dark: #1a1a2e;
    --secondary-dark: #16213e;
    --accent-cyan: #00d4ff;
    --accent-orange: #ff6b35;
    --text-light: #ffffff;
    --text-muted: #a0a9c0;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-glow: 0 8px 32px rgba(0, 212, 255, 0.3);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: 
        linear-gradient(135deg, rgba(26, 26, 46, 0.95) 0%, rgba(22, 33, 62, 0.95) 100%),
        radial-gradient(circle at 20% 80%, rgba(0, 212, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 107, 53, 0.15) 0%, transparent 50%);
    background-attachment: fixed;
    background-size: cover;
    min-height: 100vh;
    color: var(--text-light);
    overflow-x: hidden;
}

/* Background overlay para logo como watermark */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../img/logo.png');
    background-position: center;
    background-repeat: no-repeat;
    background-size: 40vh;
    opacity: 0.03;
    z-index: -1;
    pointer-events: none;
}

/* === LAYOUT PRINCIPAL === */

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

.control-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 60px 40px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    animation: fadeInUp 0.8s ease-out;
}

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

/* === HEADER COM LOGO === */

.app-header {
    margin-bottom: 40px;
}

.app-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
}

.app-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-orange));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

.app-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 400;
    line-height: 1.6;
}

/* === SEÇÃO DE AÇÃO PRINCIPAL === */

.action-section {
    margin: 40px 0;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 50px;
    padding: 12px 24px;
    margin-bottom: 30px;
    font-size: 0.9rem;
    color: var(--accent-cyan);
    font-weight: 500;
}

.status-indicator::before {
    content: '●';
    margin-right: 8px;
    animation: pulse 2s infinite;
}

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

.main-button {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-orange));
    border: none;
    border-radius: 15px;
    padding: 20px 50px;
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 10px 25px rgba(0, 212, 255, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    min-width: 200px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

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

.main-button:hover {
    transform: translateY(-3px);
    box-shadow: 
        0 15px 35px rgba(0, 212, 255, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.main-button:hover::before {
    left: 100%;
}

.main-button:active {
    transform: translateY(-1px);
}

.main-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Spinner de carregamento */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

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

.main-button.loading .loading-spinner {
    display: block;
}

.main-button.loading .button-text {
    display: none;
}

/* === INFORMAÇÕES ADICIONAIS === */

.info-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--glass-border);
}

.info-item {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 15px;
}

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

/* === CONFIGURACAO E LISTAGEM === */

.dashboard-panel {
    max-width: 640px;
}

.login-panel {
    max-width: 460px;
}

.login-form {
    margin-top: 10px;
    text-align: left;
}

.login-button {
    margin-top: 6px;
    width: 100%;
}

.settings-panel {
    max-width: 1080px;
    text-align: left;
    padding: 40px;
}

.compact-header {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 28px;
}

.compact-header .app-logo {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    margin: 0;
}

.compact-header .app-title,
.compact-header .app-subtitle {
    text-align: left;
}

.section-label {
    display: inline-flex;
    color: var(--accent-cyan);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 22px;
}

.flash-message {
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 12px 14px;
}

.flash-success {
    background: rgba(0, 255, 136, 0.12);
    border: 1px solid rgba(0, 255, 136, 0.28);
    color: #00ff88;
}

.flash-error {
    background: rgba(255, 71, 87, 0.12);
    border: 1px solid rgba(255, 71, 87, 0.28);
    color: #ff7b86;
}

.active-device-card,
.empty-state,
.form-card,
.device-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 20px;
}

.active-device-card {
    margin-bottom: 28px;
    text-align: left;
}

.active-device-card h2,
.empty-state h2,
.device-item h2 {
    color: var(--text-light);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.active-device-card p,
.empty-state p,
.device-item p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.device-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.device-meta span {
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    color: var(--text-muted);
    font-family: "Courier New", monospace;
    font-size: 0.82rem;
    padding: 7px 10px;
}

.secondary-link {
    color: var(--accent-cyan);
    font-weight: 700;
    text-decoration: none;
}

.secondary-link:hover {
    color: var(--accent-orange);
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
    gap: 24px;
    align-items: start;
}

.device-form {
    display: grid;
    gap: 16px;
}

.device-form label {
    color: var(--text-light);
    display: grid;
    font-size: 0.9rem;
    font-weight: 600;
    gap: 8px;
}

.device-form input {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    color: var(--text-light);
    font: inherit;
    min-height: 44px;
    outline: none;
    padding: 11px 12px;
    width: 100%;
}

.device-form input:focus {
    border-color: rgba(0, 212, 255, 0.75);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.12);
}

.form-row {
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 1fr) minmax(120px, 0.4fr);
}

.checkbox-line {
    align-items: center;
    display: flex !important;
    gap: 10px !important;
}

.checkbox-line input {
    min-height: auto;
    width: 18px;
}

.form-actions,
.item-actions,
.footer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.primary-action,
.secondary-action,
.text-action {
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
}

.primary-action {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-orange));
    color: white;
    min-height: 44px;
    padding: 12px 18px;
}

.secondary-action {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-light);
    min-height: 44px;
    padding: 12px 18px;
}

.device-list {
    display: grid;
    gap: 14px;
}

.device-item.active {
    border-color: rgba(0, 212, 255, 0.45);
    box-shadow: 0 0 0 1px rgba(0, 212, 255, 0.12);
}

.device-summary {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.active-badge {
    background: rgba(0, 255, 136, 0.12);
    border: 1px solid rgba(0, 255, 136, 0.35);
    border-radius: 999px;
    color: #00ff88;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 6px 10px;
    text-transform: uppercase;
}

.item-actions {
    margin-top: 16px;
}

.text-action {
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent-cyan);
    min-height: 36px;
    padding: 8px 12px;
}

.text-action.danger {
    color: #ff7b86;
}

.footer-actions {
    border-top: 1px solid var(--glass-border);
    margin-top: 28px;
    padding-top: 22px;
}

/* === RESPONSIVIDADE === */

@media (max-width: 768px) {
    .control-panel {
        padding: 40px 30px;
        margin: 10px;
        max-width: none;
    }
    
    .app-title {
        font-size: 2rem;
    }
    
    .main-button {
        padding: 18px 40px;
        font-size: 1.1rem;
        min-width: 180px;
    }
    
    .app-logo {
        width: 60px;
        height: 60px;
    }

    .settings-panel {
        padding: 30px 22px;
    }

    .settings-grid,
    .form-row {
        grid-template-columns: 1fr;
    }

    .compact-header {
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .control-panel {
        padding: 30px 20px;
    }
    
    .app-title {
        font-size: 1.8rem;
    }
    
    .main-button {
        padding: 16px 35px;
        font-size: 1rem;
        min-width: 160px;
    }

    .compact-header {
        display: grid;
    }

    .device-summary,
    .form-actions {
        display: grid;
    }
}
