/* ============================================
   Site Manager - Stylesheet
   ============================================ */

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;

    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-light: #f8fafc;

    --border-color: #e2e8f0;
    --border-radius: 8px;

    --sidebar-width: 240px;
    --header-height: 60px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-body);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.875em;
    background: var(--bg-body);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ============================================
   Layout
   ============================================ */

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.version {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-light);
    opacity: 0.7;
    transition: all 0.2s;
}

.nav-item:hover {
    opacity: 1;
    background: rgba(255,255,255,0.05);
    text-decoration: none;
}

.nav-item.active {
    opacity: 1;
    background: rgba(255,255,255,0.1);
    border-right: 3px solid var(--primary);
}

.nav-icon {
    margin-right: 12px;
    font-size: 1.2em;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.user-icon {
    margin-right: 8px;
    font-size: 1.2em;
}

.username {
    font-weight: 500;
}

.user-actions {
    display: flex;
    gap: 8px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-height: 100vh;
}

/* ============================================
   Components
   ============================================ */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:hover {
    background: var(--bg-body);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    border-color: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    opacity: 0.9;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-small {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-block {
    display: block;
    width: 100%;
}

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

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card h3 {
    margin-bottom: 16px;
    font-size: 1.1rem;
    font-weight: 600;
}

.card-danger {
    border: 1px solid var(--danger);
}

.card-danger h3 {
    color: var(--danger);
}

.card-actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
}

.card-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header-actions h3 {
    margin-bottom: 0;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-title {
    display: flex;
    flex-direction: column;
}

.header-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

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

/* Stats Cards */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 4px;
}

.stat-success .stat-value { color: var(--success); }
.stat-danger .stat-value { color: var(--danger); }
.stat-warning .stat-value { color: var(--warning); }

/* Sites Grid */
.sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.site-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.site-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.site-name {
    font-weight: 600;
    margin: 0;
}

.site-status {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.status-ok { background: #dcfce7; color: #166534; }
.status-path_not_found,
.status-not_git_repo,
.status-not_whitelisted { background: #fee2e2; color: #991b1b; }
.status-unknown { background: #f3f4f6; color: #6b7280; }

.site-card-body {
    padding: 16px;
}

.site-info {
    margin-bottom: 12px;
}

.site-domain {
    color: var(--text-secondary);
}

.site-template,
.site-sync {
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.template-label,
.sync-label {
    color: var(--text-muted);
}

.template-version {
    font-weight: 500;
}

.template-unknown {
    color: var(--text-muted);
}

.site-card-actions {
    padding: 12px 16px;
    background: var(--bg-body);
    display: flex;
    gap: 8px;
}

/* Status Grid */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

/* Info List */
.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
}

.info-list dt {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.info-list dd {
    font-weight: 500;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
}

.data-table tr:hover {
    background: var(--bg-body);
}

.row-inactive {
    opacity: 0.6;
}

.actions-cell {
    white-space: nowrap;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-secondary { background: #f3f4f6; color: #6b7280; }

/* Forms */
.form-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section h3 {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-card);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-help {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-check label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.form-check input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 24px;
}

/* Alerts */
.flash-messages {
    margin-bottom: 20px;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #e0f2fe; color: #075985; }

.alert-close {
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    opacity: 0.5;
}

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

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

.tab {
    padding: 12px 20px;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text-primary);
    text-decoration: none;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Console Output */
.console-output {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--border-radius);
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 400px;
    overflow-y: auto;
}

.console-inline {
    min-height: 100px;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-lg {
    max-width: 800px;
}

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

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    opacity: 0.5;
    line-height: 1;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-inline {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.pagination-info {
    color: var(--text-muted);
}

/* Versions */
.version-section {
    margin-bottom: 24px;
}

.version-section h4 {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.version-list {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    max-height: 300px;
    overflow-y: auto;
}

.version-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.version-item:last-child {
    border-bottom: none;
}

.version-item:hover {
    background: var(--bg-body);
}

.version-item.current {
    background: #eff6ff;
}

.version-info {
    flex: 1;
}

.version-name {
    font-weight: 600;
}

.version-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.version-actions {
    margin-left: 16px;
}

/* Utility */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

.mt-4 { margin-top: 24px; }
.mb-4 { margin-bottom: 24px; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 16px;
}

/* Deploy Mode Toggle */
.deploy-mode-toggle {
    display: flex;
    gap: 12px;
}

.radio-toggle {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    flex: 1;
    transition: all 0.2s;
}

.radio-toggle:hover {
    border-color: var(--primary);
}

.radio-toggle input[type="radio"] {
    width: auto;
    margin-right: 8px;
}

.radio-toggle input[type="radio"]:checked + .radio-label {
    color: var(--primary);
    font-weight: 600;
}

.radio-toggle:has(input:checked) {
    border-color: var(--primary);
    background: #eff6ff;
}

.radio-label {
    font-weight: 500;
    margin-bottom: 2px;
}

.radio-toggle small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Input with Button */
.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button input {
    flex: 1;
}

.input-with-button .btn {
    white-space: nowrap;
    height: auto;
}

/* Guide Navigation */
.guide-nav {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 16px 20px;
    margin-bottom: 20px;
    position: sticky;
    top: 10px;
    z-index: 10;
}

.guide-nav-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.guide-nav-list a {
    display: inline-block;
    padding: 6px 12px;
    background: var(--bg-body);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.guide-nav-list a:hover {
    background: var(--primary);
    color: white;
    text-decoration: none;
}

/* Plesk-specific detail styles */
.plesk-info {
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-radius: var(--border-radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.875rem;
}

/* ============================================
   Login Page
   ============================================ */

.login-page {
    background: linear-gradient(135deg, var(--bg-sidebar) 0%, #334155 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.login-title {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 8px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-footer {
    text-align: center;
    color: rgba(255,255,255,0.5);
    margin-top: 20px;
    font-size: 0.875rem;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

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

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .stats-row {
        grid-template-columns: 1fr 1fr;
    }

    .sites-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Templates */
.versions-result {
    margin-top: 8px;
    font-size: 13px;
}

.versions-result .badge {
    margin-right: 4px;
}

.repo-url {
    font-size: 12px;
    word-break: break-all;
}

.text-danger {
    color: #dc3545;
}

.mt-4 {
    margin-top: 20px;
}

/* Repo Chooser */
.repo-list {
    max-height: 400px;
    overflow-y: auto;
}

.repo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: background 0.15s;
}

.repo-item:hover {
    background: #f0f7ff;
}

.repo-item-info {
    flex: 1;
    min-width: 0;
}

.repo-item-info strong {
    margin-right: 8px;
}

.repo-item-url {
    margin-left: 16px;
    flex-shrink: 0;
}

.repo-item-url code {
    font-size: 11px;
    color: #6c757d;
}

/* ============================================
   Wizard
   ============================================ */

.wizard-steps {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 24px;
    padding: 16px 0;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    color: var(--text-muted);
    font-size: 0.875rem;
    transition: all 0.2s;
}

.wizard-step.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.wizard-step.completed {
    background: #dcfce7;
    color: #166534;
}

.wizard-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid currentColor;
    font-size: 12px;
    font-weight: 700;
}

.wizard-step.active .wizard-step-number {
    background: white;
    color: var(--primary);
    border-color: white;
}

.wizard-step.completed .wizard-step-number {
    background: #166534;
    color: white;
    border-color: #166534;
}

.wizard-step-label {
    display: none;
}

@media (min-width: 640px) {
    .wizard-step-label {
        display: inline;
    }
}

.wizard-panel {
    animation: fadeIn 0.2s ease-in;
}

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

/* ============================================
   Scaffold Chooser
   ============================================ */

.scaffold-chooser {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.scaffold-option {
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
}

.scaffold-option:hover {
    border-color: var(--primary);
    background: #f0f7ff;
}

.scaffold-option.selected {
    border-color: var(--primary);
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.scaffold-option-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

/* ============================================
   Placeholder Builder
   ============================================ */

.placeholder-builder .data-table input {
    padding: 6px 8px;
    font-size: 13px;
}

.placeholder-builder .data-table td {
    padding: 6px 8px;
}

/* ============================================
   Setup Console
   ============================================ */

.setup-console {
    min-height: 200px;
    max-height: 500px;
}
