/* Dark Theme & Modern UI */
:root {
    --bg-dark: #121212;
    --bg-card: #1E1E1E;
    --bg-sidebar: #181818;
    --border: #333;
    --primary: #00A884;
    --primary-hover: #008f6f;
    --text-main: #E9E9E9;
    --text-muted: #888;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', sans-serif;
}

body {
    background: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.layout {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.brand {
    padding: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
}

.btn-create {
    margin: 15px;
    padding: 12px;
    background: var(--primary);
    border: none;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 168, 132, 0.3);
}

.btn-create:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 168, 132, 0.5);
}

.btn-create:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 168, 132, 0.3);
}

.instances-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.instance-item {
    padding: 15px;
    background: var(--bg-card);
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideIn 0.3s ease-out;
}

.instance-item:hover {
    border-color: var(--primary);
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0, 168, 132, 0.2);
}

.instance-item.active {
    background: #252525;
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(0, 168, 132, 0.3);
}

.instance-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #666;
}

.instance-status.connected {
    background: #00A884;
    box-shadow: 0 0 8px #00A884;
}

.instance-status.qr {
    background: #EAB308;
}

/* Main */
.main {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    position: relative;
}

.empty-view {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    opacity: 0.7;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    color: var(--primary);
}

/* Instance View */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    background: #666;
    font-weight: 600;
    transition: all 0.3s ease;
}

.badge.connected {
    background: #00A884;
    color: white;
    animation: pulse 2s ease-in-out infinite;
}

.badge.reconnecting {
    background: #EAB308;
    color: black;
    animation: blink 1s ease-in-out infinite;
}

.btn-action {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    background: #444;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-action::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-action:hover::before {
    width: 300px;
    height: 300px;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background: #555;
}

.btn-action.warning {
    background: #f59e0b;
}

.btn-action.warning:hover {
    background: #d97706;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.btn-action.danger {
    background: var(--danger);
}

.btn-action.danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Tabs */
.tabs {
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    display: flex;
    gap: 20px;
}

.tab {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 10px 0;
    cursor: pointer;
    font-size: 1rem;
    position: relative;
}

.tab.active {
    color: var(--primary);
    font-weight: 600;
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fade 0.3s;
}

/* Grid */
.grid-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 1000px) {
    .grid-layout {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    border-color: #444;
}

.card h3 {
    margin-bottom: 20px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.field-group {
    margin-bottom: 15px;
}

.field-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.copy-field {
    display: flex;
    gap: 5px;
}

.copy-field input {
    flex: 1;
    background: #111;
    border: 1px solid var(--border);
    padding: 10px;
    color: white;
    border-radius: 6px;
    font-family: monospace;
}

.copy-field button {
    background: #333;
    border: none;
    color: white;
    width: 40px;
    border-radius: 6px;
    cursor: pointer;
}

.copy-field button:hover {
    background: var(--primary);
}

.token-input {
    -webkit-text-security: disc;
}

.token-input.visible {
    -webkit-text-security: none;
}

/* Statistics Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    animation: fade 0.5s ease-out;
}

.stat-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    border-color: var(--primary);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #007a6a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 168, 132, 0.3);
}

.stat-icon.received {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.stat-icon.sent {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.stat-info h4 {
    font-size: 1.8rem;
    color: var(--text-main);
    margin: 0;
    font-weight: 700;
}

.stat-info p {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.85rem;
}

/* QR Wrapper */
.qr-wrapper {
    background: white;
    padding: 15px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    margin-bottom: 15px;
    position: relative;
}

.qr-wrapper img {
    max-width: 100%;
    width: 250px;
    height: 250px;
}

.qr-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #333;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.conn-state.success {
    text-align: center;
    padding: 50px 0;
    color: #00A884;
}

.big-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

/* Code Helpers */
.code-box {
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.code-head {
    background: #252525;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.code-head button {
    background: transparent;
    border: 1px solid #555;
    color: #ccc;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
}

pre {
    background: #111;
    padding: 15px;
    overflow-x: auto;
    color: #a5b3ce;
    margin: 0;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: var(--bg-card);
    width: 400px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-head {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-head button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
}

.modal-body {
    padding: 20px;
}

.modal-body input[type="text"] {
    width: 100%;
    padding: 10px;
    background: #111;
    border: 1px solid var(--border);
    color: white;
    border-radius: 6px;
    margin-bottom: 15px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.btn-primary.full {
    width: 100%;
}

@keyframes fade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(0, 168, 132, 0.7);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(0, 168, 132, 0);
    }
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Toggles/Switch */
.toggles-container {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    align-items: center;
    background: #111;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.toggle-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    color: var(--text-main);
}

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: .4s;
    border-radius: 34px;
    border: 1px solid #555;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: #888;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: rgba(0, 168, 132, 0.3);
    border-color: var(--primary);
}

input:checked+.slider:before {
    background-color: var(--primary);
    transform: translateX(22px);
    box-shadow: 0 0 10px rgba(0, 168, 132, 0.5);
}

.btn-small {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: white;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-small.primary {
    background: var(--primary);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn-small.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 25px 0;
}

/ *   T o g g l e s / S w i t c h   * /     . t o g g l e s - c o n t a i n e r    {
                 d i s p l a y :    f l e x ;
                 g a p :    2 0 p x ;
                 f l e x - w r a p :    w r a p ;
         
}

         . t o g g l e - i t e m    {
                 d i s p l a y :    f l e x ;
                 a l i g n - i t e m s :    c e n t e r ;
                 g a p :    1 0 p x ;
         
}

         . s w i t c h    {
                 p o s i t i o n :    r e l a t i v e ;
                 d i s p l a y :    i n l i n e - b l o c k ;
                 w i d t h :    4 0 p x ;
                 h e i g h t :    2 0 p x ;
         
}

         . s w i t c h   i n p u t    {
                 o p a c i t y :    0 ;
                 w i d t h :    0 ;
                 h e i g h t :    0 ;
         
}

         . s l i d e r    {
                 p o s i t i o n :    a b s o l u t e ;
                 c u r s o r :    p o i n t e r ;
                 t o p :    0 ;
                 l e f t :    0 ;
                 r i g h t :    0 ;
                 b o t t o m :    0 ;
                 b a c k g r o u n d - c o l o r :    # 4 4 4 ;
                 t r a n s i t i o n :    . 4 s ;
                 b o r d e r - r a d i u s :    2 0 p x ;
         
}

         . s l i d e r : b e f o r e    {
                 p o s i t i o n :    a b s o l u t e ;
                 c o n t e n t :    " "  ;
                 h e i g h t :    1 6 p x ;
                 w i d t h :    1 6 p x ;
                 l e f t :    2 p x ;
                 b o t t o m :    2 p x ;
                 b a c k g r o u n d - c o l o r :    w h i t e ;
                 t r a n s i t i o n :    . 4 s ;
                 b o r d e r - r a d i u s :    5 0 % ;
         
}

         i n p u t : c h e c k e d   +   . s l i d e r    {
                 b a c k g r o u n d - c o l o r :    v a r ( - - p r i m a r y ) ;
         
}

         i n p u t : f o c u s   +   . s l i d e r    {
                 b o x - s h a d o w :    0   0   1 p x   v a r ( - - p r i m a r y ) ;
         
}

         i n p u t : c h e c k e d   +   . s l i d e r : b e f o r e    {
                 t r a n s f o r m :    t r a n s l a t e X ( 2 0 p x ) ;
         
}

         . b t n - s m a l l    {
                 p a d d i n g :    8 p x   1 2 p x ;
                 b o r d e r :    n o n e ;
                 b o r d e r - r a d i u s :    6 p x ;
                 c u r s o r :    p o i n t e r ;
                 f o n t - s i z e :    0 . 9 r e m ;
                 c o l o r :    w h i t e ;
                 t r a n s i t i o n :    a l l   0 . 2 s ;
         
}

         . b t n - s m a l l . p r i m a r y    {
                 b a c k g r o u n d :    v a r ( - - p r i m a r y ) ;
         
}

         . b t n - s m a l l . p r i m a r y : h o v e r    {
                 b a c k g r o u n d :    v a r ( - - p r i m a r y - h o v e r ) ;
         
}

         . d i v i d e r    {
                 b o r d e r :    0 ;
                 b o r d e r - t o p :    1 p x   s o l i d   v a r ( - - b o r d e r ) ;
                 m a r g i n :    2 0 p x   0 ;
         
}

     