:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar: #0f172a;
    --success: #10b981;
    --error: #ef4444;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.text-secondary {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 8px;
}

.mt-4 {
    margin-top: 1rem !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 14px;
}

.btn i {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-neutral {
    background: #f1f5f9;
    color: var(--text-main);
}

.btn-neutral:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.btn-danger:hover {
    background: #fecaca;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Login Page */
.login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #e0f2fe, transparent),
        radial-gradient(circle at bottom left, #f1f5f9, transparent);
}

.login-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo-circle {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: white;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
    opacity: 0.9;
}

/* No wrapper needed without icons */

input,
textarea,
select {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    font-size: 14px;
    background: #ffffff;
    color: var(--text-main);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Input padding restored to default */

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    background: #fff;
}

input::placeholder,
textarea::placeholder {
    color: #94a3b8;
}

textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 18px;
    padding-right: 44px;
}

/* Input Groups & Copy */
.input-group {
    display: flex;
    gap: 8px;
}

.input-group input {
    flex: 1;
    background: #f8fafc;
    font-family: monospace;
    font-size: 13px;
}

.btn-copy {
    background: #f1f5f9;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: #e2e8f0;
    color: var(--primary);
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 5px);
    background: white;
    min-width: 180px;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border);
    z-index: 1000;
    /* Ensure it's above everything */
    display: none;
    overflow: hidden;
    animation: dropdownIn 0.2s ease-out;
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown.active .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    width: 100%;
    border: none;
    background: none;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f8fafc;
}

.dropdown-item i {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.dropdown-item.danger {
    color: var(--error);
}

.dropdown-item.danger i {
    color: var(--error);
}

/* Dashboard Layout */
#dashboard-view {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--sidebar);
    color: white;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 40px;
}

.logo-mini {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    background: var(--bg-main);
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}

.content-header h2 {
    font-size: 28px;
    font-weight: 700;
}

/* Table */
.table-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: visible;
    /* Changed from hidden to show dropdowns */
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #f8fafc;
    text-align: left;
    padding: 16px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

tr:last-child td {
    border-bottom: none;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-connected {
    background: #dcfce7;
    color: #15803d;
}

.badge-disconnected {
    background: #fee2e2;
    color: #b91c1c;
}

/* QR Section */
.qr-card {
    max-width: 500px;
    margin: 0 auto;
    background: white;
    border-radius: 24px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.qr-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.qr-header h3 {
    font-size: 18px;
    margin: 0;
}

.qr-placeholder {
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-muted);
}

#qr-image {
    width: 256px;
    height: 256px;
    margin: 0 auto 20px;
    display: block;
    border: 8px solid white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Success Illustration */
.success-illustration {
    margin: 40px 0 24px;
    display: flex;
    justify-content: center;
}

.success-circle {
    width: 80px;
    height: 80px;
    background: #dcfce7;
    color: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.success-circle i {
    width: 40px;
    height: 40px;
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    60% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    width: 95%;
    max-width: 500px;
    border-radius: 28px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header {
    margin-bottom: 24px;
    padding-right: 40px;
    /* Room for absolute close button */
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.modal-close {
    position: absolute;
    top: 24px;
    right: 24px;
    color: var(--text-muted);
    transition: all 0.2s;
    background: #f8fafc;
    border-radius: 10px;
}

.modal-close:hover {
    background: #f1f5f9;
    color: var(--error);
    transform: rotate(90deg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
}

/* Specific Message Modal Tweaks */
#send-message-form textarea {
    margin-top: 4px;
}



/* Toast */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 10000;
    pointer-events: none;
    /* Allow clicking through container */
}

.toast {
    padding: 16px 24px;
    background: #ffffff;
    color: #1e293b;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
    pointer-events: auto;
    /* Re-enable clicks on toast */
    border: 1px solid #e2e8f0;
    min-width: 300px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 20px 10px;
    }

    .sidebar-header span,
    .nav-item span {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .sidebar-header {
        justify-content: center;
        margin-bottom: 30px;
    }
}

@media (max-width: 768px) {
    #dashboard-view {
        flex-direction: column;
        overflow: hidden;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        position: relative;
        z-index: 50;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    }

    .sidebar-header {
        margin-bottom: 0;
        font-size: 14px;
    }

    .logo-mini {
        width: 28px;
        height: 28px;
    }

    .logo-mini i {
        width: 14px;
    }

    .sidebar-nav {
        flex-direction: row;
        gap: 8px;
    }

    .nav-item {
        padding: 8px;
        border-radius: 8px;
    }

    .nav-item i {
        width: 18px;
    }

    .main-content {
        padding: 16px;
        height: calc(100vh - 60px);
        overflow-y: auto;
    }

    .content-header {
        margin-bottom: 24px;
    }

    .content-header h2 {
        font-size: 20px;
    }

    /* Table to Card Transition */
    .table-card {
        background: none;
        border: none;
        box-shadow: none;
        overflow: visible;
        width: 100%;
    }

    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block !important;
        width: 100% !important;
    }

    thead {
        display: none !important;
    }

    tr {
        background: white;
        border-radius: 24px;
        padding: 24px;
        margin-bottom: 20px;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        border: 1px solid var(--border);
        animation: cardFade 0.4s ease-out;
    }

    @keyframes cardFade {
        from {
            opacity: 0;
            transform: translateY(10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    td {
        border: none !important;
        padding: 10px 0;
        display: flex !important;
        justify-content: space-between;
        align-items: center;
    }

    td[data-label]::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    td:last-child {
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px dashed var(--border) !important;
        justify-content: flex-end;
        /* Align right */
        gap: 15px;
    }

    td:last-child::before {
        display: none;
        /* Hide label */
    }

    .modal-content {
        padding: 30px 20px;
        border-radius: 24px;
    }

    .modal-close {
        top: 16px;
        right: 16px;
    }
}