@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent: #25D366;
    /* WhatsApp Green */
    --accent-dark: #128C7E;
    --danger: #ef4444;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
}

header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--accent-dark);
}

nav a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    margin-left: 1.5rem;
    transition: color 0.2s;
}

nav a:hover,
nav a.active {
    color: var(--accent-dark);
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

h1,
h2,
h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

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

button {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: var(--accent-dark);
}

button.secondary {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

button.secondary:hover {
    border-color: var(--text-secondary);
    background-color: #f1f5f9;
}

button.danger {
    background-color: var(--danger);
}

button.danger:hover {
    background-color: #dc2626;
}

/* Dashboard Grid */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.device-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
    position: relative;
    overflow: hidden;
}

.device-card:hover {
    transform: translateY(-2px);
}

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

.device-id {
    font-weight: 700;
    font-size: 1.1rem;
}

.status-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-READY {
    background-color: #dcfce7;
    color: #166534;
}

.status-INITIALIZING {
    background-color: #fff7ed;
    color: #9a3412;
}

.status-QR_READY {
    background-color: #fef08a;
    color: #854d0e;
}

.status-AUTHENTICATED {
    background-color: #dbeafe;
    color: #1e40af;
}

.device-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.device-actions button {
    flex: 1;
    font-size: 0.875rem;
}

/* Logs and Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow);
}

.modal input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin: 1rem 0;
    font-size: 1rem;
}

.log-container {
    background: #1e1e1e;
    color: #e0e0e0;
    padding: 1rem;
    border-radius: 0.5rem;
    height: 400px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.9rem;
}

.log-entry {
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #333;
    padding-bottom: 0.25rem;
}

.log-time {
    color: #888;
    font-size: 0.75rem;
}

.qr-code-img {
    display: block;
    margin: 1rem auto;
    max-width: 100%;
}

/* Docs */
.docs-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
}

.docs-content h3 {
    margin-top: 2rem;
    color: var(--accent-dark);
}

.docs-content code {
    background: #f1f5f9;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: monospace;
    font-size: 0.9em;
}

.docs-content pre {
    background: #1e1e1e;
    color: #e0e0e0;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
}

/* Full Screen Opaque Login */
#login-modal.modal-overlay {
    background-color: var(--bg-color);
    /* Opaque background */
    z-index: 9999;
    /* Top level */
    opacity: 1;
    /* Ensure no transparency */
}

/* Filter Options */
.filter-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-option:hover {
    border-color: var(--accent);
    background: #f0fdf4;
}

.filter-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.filter-label {
    font-weight: 500;
    font-size: 0.95rem;
}