﻿/* Applications Page CSS */

body { background: var(--bg, #f8fafc); display: flex; min-height: 100vh; }

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

/* AI Generator specific styles */
.example-btn {
    transition: all 0.2s;
}

.example-btn:hover {
    background: #e0f2fe !important;
    border-color: #0ea5e9 !important;
    transform: translateY(-1px);
}

/* App Cards Grid */
/* App Cards Grid — responsive fluid */
.app-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.app-card {
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: 20px;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
}

.app-card:hover {
    border-color: var(--gray-300);
    box-shadow: var(--shadow-md);
}

.app-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.app-card-avatar {
    width: 50px;
    height: 50px;
    min-width: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 800;
}

.app-card-info {
    min-width: 0;
}

.app-card-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 5px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-card-date {
    font-size: 0.78rem;
    color: var(--gray-400);
}

.app-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: auto;
}

.app-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 0;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.app-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.app-action-btn.act-open { background: #dcfce7; color: #166534; }
.app-action-btn.act-open:hover { background: #bbf7d0; }
.app-action-btn.act-api { background: #dbeafe; color: #1d4ed8; }
.app-action-btn.act-api:hover { background: #bfdbfe; }
.app-action-btn.act-edit { background: #fef3c7; color: #92400e; }
.app-action-btn.act-edit:hover { background: #fde68a; }
.app-action-btn.act-security { background: #fee2e2; color: #991b1b; }
.app-action-btn.act-security:hover { background: #fecaca; }
.app-action-btn.act-rebuild { background: #ede9fe; color: #5b21b6; }
.app-action-btn.act-rebuild:hover { background: #ddd6fe; }
.app-action-btn.act-delete { background: #fee2e2; color: #991b1b; }
.app-action-btn.act-delete:hover { background: #fecaca; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 20px;
    margin-top: 16px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--surface);
    color: var(--gray-600);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-xs);
}

.page-btn:hover:not(:disabled) {
    background: var(--primary-50);
    color: var(--primary-700);
    box-shadow: var(--shadow-sm);
}

.page-btn.active {
    background: var(--primary-600);
    color: white;
    box-shadow: 0 2px 8px rgb(99 102 241 / 0.3);
}

.page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.page-info {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-left: 12px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.app-info h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.app-meta {
    font-size: 0.8125rem;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.status-inactive {
    background: #fef2f2;
    color: #991b1b;
}

.app-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

/* App Icon Avatar */
.app-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Open App Primary Button */
.app-btn-open {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--primary-200);
    background: var(--primary-50);
    color: var(--primary-700);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-top: 14px;
}

.app-btn-open:hover {
    background: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
    box-shadow: 0 2px 8px rgb(99 102 241 / 0.25);
}

/* Icon-only Action Row */
.app-actions-row {
    display: flex;
    gap: 4px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
}

.app-action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    background: var(--gray-50);
    color: var(--gray-500);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.app-action-icon:hover {
    background: var(--primary-50);
    color: var(--primary-600);
}

.app-action-icon:nth-child(1):hover { background: #dbeafe; color: #2563eb; }
.app-action-icon:nth-child(2):hover { background: #fef3c7; color: #d97706; }
.app-action-icon:nth-child(3):hover { background: #dcfce7; color: #16a34a; }
.app-action-icon:nth-child(4):hover { background: #ede9fe; color: #7c3aed; }

.app-action-icon.danger:hover {
    background: #fee2e2;
    color: #dc2626;
}

.app-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.app-btn-primary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.app-btn-primary:hover {
    background: #e2e8f0;
    color: #334155;
}

.app-btn-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.app-btn-success:hover {
    background: #bbf7d0;
}

.app-btn-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.app-btn-warning:hover {
    background: #fde68a;
}

.app-btn-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.app-btn-danger:hover {
    background: #fecaca;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, #eef2ff 0%, #f0f9ff 50%, #f8fafc 100%);
    border-radius: var(--radius-xl);
    border: none;
    box-shadow: var(--shadow-sm);
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--gray-500);
    margin-bottom: 20px;
    font-size: 0.875rem;
}

.demo-app-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.demo-app-card:hover {
    border-color: var(--primary-500);
    background: var(--gray-50);
    transform: translateY(-1px);
}

/* Modal Section Header */
.modal-section-header {
    margin-bottom: 20px;
}

.modal-section-header h4 {
    margin-bottom: 8px;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-section-header p {
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Demo Apps Grid */
.demo-apps-grid {
    display: grid;
    gap: 16px;
}

/* Selection Box */
.selection-box {
    display: none;
    margin-top: 20px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
}

.selection-box h5 {
    margin-bottom: 8px;
    color: var(--gray-900);
}

.selection-box p {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

/* Feature Checkbox Grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.feature-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400 !important;
}

/* AI Progress */
.ai-progress {
    display: none;
    margin: 20px 0;
    padding: 16px;
    background: #f0f9ff;
    border: 1px solid var(--primary-300, #93c5fd);
    border-radius: var(--radius-lg);
}

.ai-progress-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.ai-progress-bar {
    background: var(--gray-200);
    border-radius: var(--radius-lg);
    height: 8px;
    overflow: hidden;
}

.ai-progress-bar-fill {
    background: var(--primary-500);
    height: 100%;
    width: 0%;
    transition: width 0.3s;
}

/* Permissions Grid */
.permissions-grid {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
}

.permissions-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 500 !important;
}

.permissions-grid input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    min-width: 160px;
    padding: 4px 0;


.context-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
}

.context-menu-item:hover {
    background: var(--gray-100);
}

.context-menu-item.danger {
    color: var(--red-600, #dc2626);
}

.context-menu-item.danger:hover {
    background: #fef2f2;
}

.context-menu-divider {
    border-top: 1px solid var(--gray-200);
    margin: 4px 0;
}

/* File Tree */
.file-tree-item {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.file-tree-item:hover {
    background: var(--gray-200);
}

.file-tree-icon {
    margin-right: 6px;
    font-size: 0.75rem;
    width: 16px;
    text-align: center;
}

.file-tree-name {
    font-size: 0.875rem;
    color: var(--gray-700);
}

.file-tree-size {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* Editor Tabs */
.editor-tab {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    background: var(--gray-200);
    margin-right: 2px;
    font-size: 0.875rem;
    color: var(--gray-700);
    white-space: nowrap;
    transition: background 0.2s;
}

.editor-tab.active {
    background: var(--surface);
    color: var(--gray-900);
}

.editor-tab-close {
    margin-left: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: 0.75rem;
}

/* File Editor Modal layout */
.editor-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.editor-header-actions .btn {
    padding: 8px 16px;
    font-size: 0.875rem;
}

/* Editor sidebar */
.editor-sidebar {
    width: 300px;
    border-right: 1px solid var(--gray-200);
    background: var(--gray-50);
    overflow-y: auto;
    display: none;
}

.editor-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
}

/* AI Panel */
.ai-panel {
    width: 350px;
    border-left: 1px solid var(--gray-200);
    background: var(--gray-50);
    display: none;
    flex-direction: column;
}

.ai-panel-header {
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-panel-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.ai-msg {
    margin-bottom: 12px;
    padding: 8px;
    border-radius: var(--radius-lg);
}

.ai-msg-user { background: #e0f2fe; }
.ai-msg-bot  { background: #f0f9ff; }

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.quick-actions .btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    text-align: left;
}

/* Preview Panel */
.preview-panel {
    width: 40%;
    border-left: 1px solid var(--gray-200);
    background: var(--surface);
    display: none;
    flex-direction: column;
}

.preview-panel-header {
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Provider Config */
.provider-config-box {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 16px;
    background: var(--gray-50);
}

/* Backup Table  */
.backup-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.backup-table th {
    padding: 6px 8px;
    color: var(--gray-500);
    font-weight: 600;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.backup-table td {
    padding: 8px;
    border-bottom: 1px solid var(--gray-100);
}

/* Sidebar Logo SVG */
.sidebar-logo-icon {
    width: 28px;
    height: 28px;
    background: var(--primary-500);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;

}

.sidebar-logo-icon svg {
    width: 16px;
    height: 16px;
    stroke: white;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* Enhanced Responsive Design */
@media (max-width: 1024px) {
    .main-layout {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .mobile-sidebar-toggle {
        display: block;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .main-layout {
        padding: 1rem;
        padding-top: 60px;
    }

    .apps-table-wrapper {
        overflow-x: auto;
    }

    .apps-table {
        min-width: 600px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
    }

    .header-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .app-actions {
        grid-template-columns: 1fr;
    }

    .app-actions-row {
        flex-wrap: wrap;
    }
}

/* â”€â”€ Form Enhancements â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.form-section {
    margin-bottom: 1.5rem;
}

.form-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row > .form-group {
    flex: 1;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--gray-400);
    margin-top: 4px;
}

.input-group {
    display: flex;
    align-items: center;
}

.input-group .form-input {
    border-radius: 8px 0 0 8px;
}

.input-group-append {
    padding: 12px 16px;
    background: var(--gray-50);
    border: 1px solid #d1d5db;
    border-left: none;
    border-radius: 0 8px 8px 0;
    font-size: 0.82rem;
    color: var(--gray-500);
}

/* â”€â”€ Skeleton Loading â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 0%, var(--gray-50) 50%, var(--gray-100) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

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

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    width: 80%;
}

.skeleton-text-sm { height: 12px; width: 60%; }
.skeleton-circle { border-radius: 50%; }
.skeleton-card { height: 120px; border-radius: var(--radius-xl); }

/* â”€â”€ Staggered entrance animation â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: slideUp 0.3s ease forwards;
    opacity: 0;
}

.animate-in:nth-child(1) { animation-delay: 0.02s; }
.animate-in:nth-child(2) { animation-delay: 0.06s; }
.animate-in:nth-child(3) { animation-delay: 0.10s; }
.animate-in:nth-child(4) { animation-delay: 0.14s; }
.animate-in:nth-child(5) { animation-delay: 0.18s; }
.animate-in:nth-child(6) { animation-delay: 0.22s; }
.animate-in:nth-child(7) { animation-delay: 0.26s; }
.animate-in:nth-child(8) { animation-delay: 0.30s; }

/* â”€â”€ App Card Enhancements â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.app-card-status-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 16px 0 0 16px;
}

.app-card-status-bar.active { background: #22c55e; }
.app-card-status-bar.failed { background: #ef4444; }
.app-card-status-bar.deploying { background: #f59e0b; }

.app-card .app-actions {
    opacity: 0.85;
    transition: opacity 0.2s;
}

.app-card:hover .app-actions {
    opacity: 1;
}
