:root {
    --bg-dark: #140d0c;
    --bg-darker: #0c0807;
    --primary: #e05638;
    --primary-glow: rgba(224, 86, 56, 0.35);
    --primary-hover: #ff6d4d;
    --secondary: #d37f5a;
    --secondary-hover: #e6916c;
    --text-main: #f5ebe6;
    --text-muted: #bdaea8;
    --glass-bg: rgba(36, 23, 21, 0.5);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.03);
    --card-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    --success: #4cd964;
    --warning: #ffcc00;
    --danger: #ff3b30;
    --font-ar: 'Cairo', sans-serif;
    --font-en: 'Outfit', sans-serif;
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-ar);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
}

/* Background blob animations */
.blob-bg {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.25;
    pointer-events: none;
    animation: pulse 12s infinite alternate;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 600px;
    height: 600px;
    background: #5a38e0;
    bottom: -200px;
    right: -100px;
    animation-delay: 3s;
}

.blob-3 {
    width: 400px;
    height: 400px;
    background: var(--secondary);
    top: 35%;
    left: 40%;
    animation-delay: 6s;
}

@keyframes pulse {
    0% {
        transform: scale(1) translate(0, 0);
        opacity: 0.2;
    }
    100% {
        transform: scale(1.2) translate(50px, 50px);
        opacity: 0.35;
    }
}

/* App Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--glass-border);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 8px 20px var(--primary-glow);
}

.logo-icon i {
    width: 26px;
    height: 26px;
}

.logo-text h1 {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(120deg, var(--text-main) 30%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text span {
    font-family: var(--font-en);
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    display: block;
    margin-top: -2px;
}

/* Connection Badges */
.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(5px);
}

.status-badge.connected {
    color: var(--success);
    border-color: rgba(76, 217, 100, 0.2);
    background: rgba(76, 217, 100, 0.05);
}

.status-badge.disconnected {
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.connected .status-dot {
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success);
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Alert Banner */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 25px;
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.2);
    color: #ff807a;
    animation: slideDown 0.3s ease;
}

.alert-banner.success {
    background: rgba(76, 217, 100, 0.1);
    border: 1px solid rgba(76, 217, 100, 0.2);
    color: #8eff9b;
}

.alert-banner.hidden {
    display: none;
}

.close-alert {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    margin-right: auto; /* Push to left in RTL */
    display: flex;
    align-items: center;
    opacity: 0.7;
    transition: var(--transition);
}

.close-alert:hover {
    opacity: 1;
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Glass Card */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-highlight), transparent);
}

/* Grid Layout */
.grid-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 30px;
}

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

/* Intro Card Specifics */
.intro-card {
    padding: 40px;
}

.hero-yarn {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.yarn-ball {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 15px 35px var(--primary-glow);
    animation: float 4s ease-in-out infinite;
}

.yarn-icon {
    width: 50px;
    height: 50px;
    color: white;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-12px) rotate(15deg); }
}

.intro-card h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 15px;
    text-align: center;
}

.description {
    color: var(--text-muted);
    font-size: 1.05rem;
    text-align: center;
    max-width: 500px;
    margin: 0 auto 35px auto;
}

.login-action-container {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

.features-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-top: 1px solid var(--glass-border);
    padding-top: 30px;
}

.feature-item {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.feat-icon {
    color: var(--secondary);
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-top: 3px;
}

.feature-item h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 3px;
}

.feature-item p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Config Card Specifics */
.config-card {
    padding: 30px;
}

.card-header-icon {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    color: var(--secondary);
}

.card-header-icon h3 {
    color: var(--text-main);
    font-size: 1.2rem;
    font-weight: 700;
}

.section-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 25px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: var(--font-ar);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn i {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #e86d54);
    color: white;
    box-shadow: 0 8px 25px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(224, 86, 56, 0.5);
    background: linear-gradient(135deg, var(--primary-hover), #ff846b);
}

.btn-large {
    padding: 16px 36px;
    font-size: 1.1rem;
    border-radius: 50px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    width: 100%;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--secondary);
}

.btn-outline {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--glass-border);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-main);
}

.btn-danger {
    background: rgba(255, 59, 48, 0.15);
    color: #ff453a;
    border: 1px solid rgba(255, 59, 48, 0.3);
}

.btn-danger:hover {
    background: rgba(255, 59, 48, 0.25);
    border-color: #ff453a;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

/* Forms */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 25px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tooltip-trigger {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    cursor: help;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    right: 14px; /* RTL placement */
    color: var(--text-muted);
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.input-wrapper input {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 12px 45px 12px 16px; /* Right padding for icon in RTL */
    color: white;
    font-family: var(--font-en);
    font-size: 0.95rem;
    transition: var(--transition);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(224, 86, 56, 0.25);
    background: rgba(0, 0, 0, 0.4);
}

.toggle-password {
    position: absolute;
    left: 14px; /* Left side for toggle in RTL */
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
}

.toggle-password:hover {
    color: var(--text-main);
}

/* Setup Guide List */
.setup-guide {
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px dashed var(--glass-border);
}

.setup-guide h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setup-guide ol {
    padding-right: 20px; /* RTL bullet margin */
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setup-guide a {
    color: var(--secondary);
    text-decoration: none;
}

.setup-guide a:hover {
    text-decoration: underline;
}

.setup-guide code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-en);
    font-size: 0.8rem;
    color: var(--secondary-hover);
}

.inline-icon {
    width: 12px;
    height: 12px;
    display: inline-block;
    vertical-align: middle;
}

/* Panels Management (Views) */
.view-panel {
    display: none;
}

.view-panel.active {
    display: block;
    animation: fadeIn 0.4s ease-in-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* VIEW 2: Dashboard Profile Card */
.profile-card {
    padding: 30px;
    margin-bottom: 40px;
}

.profile-layout {
    display: flex;
    align-items: center;
    gap: 25px;
    flex-wrap: wrap;
}

.avatar-container {
    position: relative;
    width: 100px;
    height: 100px;
}

.profile-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bg-dark);
    z-index: 2;
    position: relative;
}

.avatar-ring {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    z-index: 1;
    box-shadow: 0 0 15px var(--primary-glow);
}

.profile-details {
    flex-grow: 1;
}

.username-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 5px;
}

.username-row h2 {
    font-size: 1.6rem;
    font-weight: 700;
}

.badge {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 50px;
    font-weight: 700;
}

.badge-primary {
    background: rgba(224, 86, 56, 0.15);
    color: var(--primary-hover);
    border: 1px solid rgba(224, 86, 56, 0.3);
}

.profile-id {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 15px;
}

.profile-id i {
    width: 14px;
    height: 14px;
}

.logout-area {
    margin-right: auto; /* Push to left in RTL */
}

@media (max-width: 600px) {
    .profile-layout {
        flex-direction: column;
        text-align: center;
    }
    
    .logout-area {
        margin-right: 0;
        width: 100%;
    }
    
    .username-row {
        justify-content: center;
    }
    
    .profile-id {
        justify-content: center;
    }
}

/* Projects Section */
.projects-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title i {
    color: var(--primary);
    width: 24px;
    height: 24px;
}

.section-title h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.projects-count {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.projects-count strong {
    color: var(--primary-hover);
    font-size: 1.1rem;
}

/* Loader Container */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    gap: 15px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Empty State */
.empty-state {
    padding: 50px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.empty-icon {
    width: 50px;
    height: 50px;
    color: var(--text-muted);
    opacity: 0.5;
}

.empty-state h4 {
    font-size: 1.1rem;
    font-weight: 700;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 300px;
}

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

/* Project Card */
.project-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    transform: translateY(-5px);
    border-color: rgba(224, 86, 56, 0.4);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.project-thumbnail-wrapper {
    position: relative;
    width: 100%;
    padding-top: 65%; /* 16:10 Aspect Ratio */
    background: rgba(0, 0, 0, 0.2);
}

.project-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.project-craft-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.project-craft-badge i {
    width: 12px;
    height: 12px;
}

.project-status-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.status-in-progress {
    background: rgba(255, 204, 0, 0.2);
    color: #ffcc00;
    border: 1px solid rgba(255, 204, 0, 0.4);
}

.status-completed {
    background: rgba(76, 217, 100, 0.2);
    color: #4cd964;
    border: 1px solid rgba(76, 217, 100, 0.4);
}

.status-other {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
}

.project-body {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.project-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pattern-name {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pattern-name i {
    width: 14px;
    height: 14px;
}

.project-progress-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 10px;
    transition: width 1s ease-out;
}

/* Footer */
.app-footer {
    margin-top: auto;
    padding: 30px 0 10px 0;
    border-top: 1px solid var(--glass-border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Utility Helpers */
.hidden {
    display: none !important;
}
