/* ESP32 WOL Remote Control - Styles */
/* Modern, responsive, and mobile-friendly CSS */

* {
    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%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

/* Animated background particles */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(255,255,255,0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255,255,255,0.1) 0%, transparent 50%);
    animation: float 15s ease-in-out infinite;
    pointer-events: none;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

.container {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 32px;
    max-width: 600px;
    width: 100%;
    box-shadow:
        0 20px 60px rgba(0,0,0,0.3),
        0 0 0 1px rgba(255,255,255,0.5) inset;
    animation: slideUp 0.6s ease-out;
    position: relative;
    z-index: 1;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1 {
    color: #333;
    margin-bottom: 8px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    color: #666;
    margin-bottom: 24px;
    font-size: 14px;
    font-weight: 400;
}

.status {
    background: #f5f5f5;
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.4s ease;
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status.connected {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-color: #b1dfbb;
    animation: pulse 2s ease-in-out infinite;
}

.status.disconnected {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-color: #f1b0b7;
}

.status.connecting {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
    color: #856404;
    border-color: #ffeaa7;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.device-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid #e9ecef;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.device-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102,126,234,0.1), transparent);
    transition: left 0.5s;
}

.device-card:hover::before {
    left: 100%;
}

.device-card:hover {
    border-color: #667eea;
    transform: translateY(-4px) scale(1.02);
    box-shadow:
        0 8px 24px rgba(102,126,234,0.2),
        0 0 0 1px rgba(102,126,234,0.1) inset;
}

.device-card:active {
    transform: translateY(-2px) scale(1.01);
}

.device-name {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}

.device-info {
    color: #666;
    font-size: 12px;
    margin-bottom: 12px;
    font-family: 'Monaco', 'Menlo', monospace;
    background: rgba(0,0,0,0.03);
    padding: 6px 10px;
    border-radius: 6px;
    display: inline-block;
}

.device-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 14px;
    transition: all 0.3s;
}

.device-status.online {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    box-shadow: 0 2px 8px rgba(21,87,36,0.2);
}

.device-status.offline {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    box-shadow: 0 2px 8px rgba(114,28,36,0.2);
}

.device-status.unknown {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
    color: #856404;
    box-shadow: 0 2px 8px rgba(133,100,4,0.2);
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    box-shadow: 0 4px 12px rgba(102,126,234,0.3);
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

button:hover::before {
    width: 300px;
    height: 300px;
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(102,126,234,0.4);
}

button:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(102,126,234,0.3);
}

button:disabled {
    background: linear-gradient(135deg, #cbd5e0 0%, #a0aec0 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.info-section {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 2px solid #e9ecef;
}

.info-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.info-btn {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    box-shadow: 0 4px 12px rgba(86,171,47,0.3);
}

.info-btn:hover {
    box-shadow: 0 8px 20px rgba(86,171,47,0.4);
}

#result {
    margin-top: 20px;
    padding: 16px 18px;
    border-radius: 12px;
    display: none;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.6;
    animation: slideIn 0.4s ease-out;
    border: 2px solid transparent;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#result.success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-color: #b1dfbb;
    display: block;
}

#result.info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border-color: #abdde5;
    display: block;
}

#result.error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-color: #f1b0b7;
    display: block;
}

.mqtt-status {
    font-size: 12px;
    color: #666;
    margin-top: 24px;
    text-align: center;
    font-weight: 500;
    opacity: 0.8;
}

/* Login Container Styles */
.login-container {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 40px;
    max-width: 400px;
    width: 100%;
    box-shadow:
        0 20px 60px rgba(0,0,0,0.3),
        0 0 0 1px rgba(255,255,255,0.5) inset;
    animation: slideUp 0.6s ease-out;
    position: relative;
    z-index: 1;
}

.login-form {
    margin-top: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    color: #333;
    font-weight: 600;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s;
    background: #f8f9fa;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 4px rgba(102,126,234,0.1);
}

.form-group input::placeholder {
    color: #adb5bd;
}

.login-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102,126,234,0.4);
}

.login-btn:active {
    transform: translateY(0);
}

.error-message {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    padding: 14px 16px;
    border-radius: 12px;
    margin-top: 16px;
    font-size: 14px;
    font-weight: 500;
    display: none;
    border: 2px solid #f1b0b7;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.hidden {
    display: none !important;
}

.logout-btn {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    padding: 8px 16px;
    font-size: 12px;
    width: auto;
    margin-left: 10px;
    box-shadow: 0 2px 8px rgba(220,53,69,0.3);
}

.logout-btn:hover {
    box-shadow: 0 4px 12px rgba(220,53,69,0.4);
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.header-left {
    flex: 1;
    min-width: 200px;
}

/* ============================================ */
/* MOBILE RESPONSIVENESS */
/* ============================================ */

/* Tablets and small laptops (max-width: 768px) */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .container, .login-container {
        padding: 28px;
        border-radius: 20px;
    }

    h1 {
        font-size: 26px;
    }

    .subtitle {
        font-size: 13px;
    }
}

/* Mobile devices (max-width: 640px) */
@media (max-width: 640px) {
    body {
        padding: 10px;
    }

    .container, .login-container {
        padding: 24px;
        border-radius: 20px;
    }

    h1 {
        font-size: 24px;
    }

    .subtitle {
        font-size: 13px;
        margin-bottom: 20px;
    }

    .device-card {
        padding: 16px;
        margin-bottom: 12px;
    }

    .device-name {
        font-size: 16px;
    }

    .device-info {
        font-size: 11px;
        padding: 5px 8px;
    }

    .device-status {
        font-size: 11px;
        padding: 5px 12px;
    }

    .status {
        font-size: 13px;
        padding: 12px 14px;
    }

    button {
        padding: 12px 20px;
        font-size: 14px;
    }

    .info-buttons {
        gap: 10px;
    }

    .info-section {
        margin-top: 24px;
        padding-top: 20px;
    }

    #result {
        font-size: 13px;
        padding: 14px;
    }

    .header-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .logout-btn {
        margin-left: 0;
        width: 100%;
        max-width: 200px;
    }

    .mqtt-status {
        font-size: 11px;
    }
}

/* Small mobile devices (max-width: 400px) */
@media (max-width: 400px) {
    .container, .login-container {
        padding: 20px;
    }

    h1 {
        font-size: 22px;
    }

    .info-buttons {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    button {
        padding: 11px 18px;
        font-size: 13px;
    }

    .form-group input {
        padding: 12px 14px;
        font-size: 14px;
    }

    .login-btn {
        padding: 12px 18px;
        font-size: 15px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    button {
        padding: 16px 28px;
        font-size: 16px;
    }

    .device-card {
        padding: 18px;
    }

    .form-group input {
        padding: 16px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Landscape mobile orientation */
@media (max-height: 600px) and (orientation: landscape) {
    body {
        padding: 10px;
        align-items: flex-start;
    }

    .container, .login-container {
        margin: 20px auto;
    }
}

/* Dark mode support (optional - if users enable it in their system) */
@media (prefers-color-scheme: dark) {
    /* Currently using light theme only - you can add dark theme here if needed */
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
