:root {
    --bg-main: #050505;
    --bg-glow: #0C1AA0;
    --glass-bg: rgba(20, 20, 25, 0.4);
    --glass-bg-hover: rgba(40, 40, 50, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --text-main: #ffffff;
    --text-muted: #a1a1aa;
    --accent: #0C1AA0;
    --accent-hover: #0832B9;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html body {
    background-color: var(--bg-main);
    background-image: radial-gradient(circle at 15% 50%, var(--bg-glow), transparent 40%),
                      radial-gradient(circle at 85% 30%, #0832B9, transparent 40%);
    background-attachment: fixed;
    color: var(--text-main);
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    direction: rtl;
}

aside {
    width: 280px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    right: -100%;
    z-index: 100;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

aside[data-open="true"] {
    right: 0;
}

aside header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--glass-border);
}

aside header div {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text-main);
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.1);
}

aside header button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

aside header button:hover {
    background: var(--glass-bg-hover);
    color: var(--text-main);
    border-color: var(--glass-border-hover);
}

aside nav {
    padding: 24px 16px;
    flex: 1;
    overflow-y: auto;
}

aside nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

aside nav ul li button {
    width: 100%;
    padding: 14px 20px;
    text-align: right;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(0px);
}

aside nav ul li button:hover {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    color: var(--text-main);
    transform: translateX(-5px);
}

aside nav ul li button[data-active="true"] {
    background: var(--glass-bg-hover);
    border: 1px solid var(--glass-border-hover);
    backdrop-filter: blur(10px);
    color: var(--text-main);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

main > header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    border-bottom: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 10;
}

main > header div {
    display: flex;
    align-items: center;
    gap: 16px;
    font-weight: 700;
    color: var(--text-main);
}

main > header div button {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

main > header div button:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

main section {
    display: none;
    flex-direction: column;
    padding: 40px 32px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

main section[data-view="true"] {
    display: flex;
}

main section form {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--glass-shadow);
}

main section form h2 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
    text-align: center;
    color: var(--text-main);
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.1);
}

main section form p {
    font-size: 15px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 16px;
}

main section form label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

main section form input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 16px;
    border-radius: var(--radius-md);
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

main section form input:focus {
    border-color: var(--accent-hover);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 15px rgba(8, 50, 185, 0.3);
}

main section form button {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 16px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 8px 20px rgba(12, 26, 160, 0.4);
    backdrop-filter: blur(10px);
}

main section form button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(8, 50, 185, 0.5);
    background: linear-gradient(135deg, var(--accent-hover), #05227a);
}

main section div[data-welcome-card] {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding: 24px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

main section div[data-welcome-card] h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-main);
}

main section div[data-welcome-card] button {
    background: var(--glass-bg-hover);
    color: var(--text-main);
    border: 1px solid var(--glass-border-hover);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

main section div[data-welcome-card] button:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

main section div[data-apps-list] {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

main section div[data-apps-list] article {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all 0.3s ease;
    box-shadow: var(--glass-shadow);
}

main section div[data-apps-list] article:hover {
    transform: translateY(-5px);
    border-color: var(--glass-border-hover);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

main section div[data-apps-list] article header {
    display: flex;
    align-items: center;
    gap: 16px;
}

main section div[data-apps-list] article header > div:first-child {
    width: 56px;
    height: 56px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

main section div[data-apps-list] article header > div:first-child img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

main section div[data-apps-list] article header > div:last-child {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

main section div[data-apps-list] article header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

main section div[data-apps-list] article header p {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

main section div[data-apps-list] article button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

main section div[data-apps-list] article button:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--glass-border-hover);
}

main section[data-section="app-details"] > div:first-child {
    margin-bottom: 24px;
}

main section[data-section="app-details"] > div:first-child button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s ease;
}

main section[data-section="app-details"] > div:first-child button:hover {
    color: var(--text-main);
}

main section[data-section="app-details"] article {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 24px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--glass-shadow);
    transition: all 0.3s ease;
}

main section[data-section="app-details"] article:hover {
    border-color: var(--glass-border-hover);
}

main section[data-section="app-details"] article header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    background: transparent;
    border: none;
    padding: 0;
}

main section[data-section="app-details"] article header div[data-app-image-box] {
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

main section[data-section="app-details"] article header div[data-app-image-box] img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

main section[data-section="app-details"] article header div[data-app-text] h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 6px;
}

main section[data-section="app-details"] article header div[data-app-text] p {
    font-size: 14px;
    color: var(--text-muted);
}

main section[data-section="app-details"] article div[data-app-actions] {
    border-top: 1px solid var(--glass-border);
    padding-top: 24px;
}

main section[data-section="app-details"] article div[data-app-actions] button {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

main section[data-section="app-details"] article div[data-app-actions] button:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
}

main section[data-section="app-details"] article header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
}

main section[data-section="app-details"] article div[data-token-display],
main section[data-section="app-details"] article div[data-token-empty] {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 32px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

main section[data-section="app-details"] article div[data-token-display] div[data-token-value] {
    font-family: monospace;
    font-size: 16px;
    color: #93c5fd;
    word-break: break-all;
    direction: ltr;
    text-align: left;
    margin-bottom: 24px;
    text-shadow: 0 0 10px rgba(147, 197, 253, 0.3);
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
}

main section[data-section="app-details"] article div[data-token-display] button,
main section[data-section="app-details"] article div[data-token-empty] button {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(12, 26, 160, 0.4);
    width: auto;
    min-width: 200px;
}

main section[data-section="app-details"] article div[data-token-display] button:hover,
main section[data-section="app-details"] article div[data-token-empty] button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(8, 50, 185, 0.5);
    background: linear-gradient(135deg, var(--accent-hover), #05227a);
}

main section[data-section="app-details"] article div[data-token-empty] p {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

main section[data-section="settings"] article {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--glass-shadow);
}

main section[data-section="settings"] article header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    background: transparent;
    border: none;
    padding: 0;
}

main section[data-section="settings"] article header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
}

main section[data-section="settings"] article p {
    font-size: 16px;
    color: var(--text-muted);
}

main section[data-section="settings"] article p span {
    color: var(--text-main);
    font-weight: 700;
    margin-right: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
}

div[role="dialog"] {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    background: rgba(10, 15, 30, 0.8);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-top: 1px solid var(--glass-border);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    padding: 32px;
    transition: bottom 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 1000;
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.8);
    max-height: 90dvh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

div[role="dialog"][aria-modal="true"] {
    bottom: 0;
}

div[role="dialog"]::before {
    content: '';
    display: block;
    width: 48px;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    margin: 0 auto 24px;
    flex-shrink: 0;
}

div[role="dialog"] h2 {
    font-size: 24px;
    margin-bottom: 12px;
    text-align: right;
    color: var(--text-main);
    font-weight: 800;
}

div[role="dialog"] p {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 24px;
    text-align: right;
    line-height: 1.6;
}

div[role="dialog"] label[data-upload-label] {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed var(--glass-border-hover);
    padding: 24px;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

div[role="dialog"] label[data-upload-label]:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-color: var(--accent-hover);
}

div[role="dialog"] img[data-preview-image] {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin: 0 auto 20px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

div[role="dialog"] input[type="text"] {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 16px;
    border-radius: var(--radius-md);
    font-size: 15px;
    outline: none;
    margin-bottom: 24px;
    transition: all 0.3s ease;
}

div[role="dialog"] input[type="text"]:focus {
    border-color: var(--accent-hover);
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 15px rgba(8, 50, 185, 0.3);
}

div[role="dialog"] div:last-child {
    display: flex;
    gap: 16px;
}

div[role="dialog"] div:last-child button {
    flex: 1;
    padding: 16px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

div[role="dialog"] div:last-child button:first-child {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}

div[role="dialog"] div:last-child button:first-child:hover {
    background: rgba(255, 255, 255, 0.15);
}

div[role="dialog"] div:last-child button:last-child {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(12, 26, 160, 0.4);
}

div[role="dialog"] div:last-child button:last-child:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(8, 50, 185, 0.5);
}

div[role="dialog"] div[data-new-token-value] {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 20px;
    font-family: monospace;
    font-size: 15px;
    color: #93c5fd;
    word-break: break-all;
    direction: ltr;
    text-align: left;
    margin-bottom: 24px;
    text-shadow: 0 0 10px rgba(147, 197, 253, 0.3);
}

div[role="status"] {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 15px;
    font-weight: 600;
    z-index: 2000;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    width: max-content;
    max-width: 90vw;
    color: var(--text-main);
}

div[role="status"][data-show="true"] {
    transform: translateX(-50%) translateY(0);
}

div[role="status"] button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

div[role="status"] button:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-main);
}

div[data-skeleton="true"] {
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-lg);
    height: 120px;
    margin-bottom: 20px;
    border: 1px solid var(--glass-border);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (min-width: 769px) {
    aside {
        position: static;
        right: 0;
    }
    aside header button {
        display: none;
    }
    main > header div button[data-action="open-menu"] {
        display: none;
    }
}

@media (max-width: 768px) {
    main section {
        padding: 24px 16px;
    }
    main > header {
        padding: 16px;
    }
    main section div[data-welcome-card] {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    main section div[data-welcome-card] button {
        width: 100%;
        justify-content: center;
    }
    main section div[data-apps-list] {
        grid-template-columns: 1fr;
    }
    main section[data-section="app-details"] article header {
        flex-direction: column;
        align-items: flex-start;
    }
}