/* ============================================
   WEBCLAUDE STYLESHEET
   Login, Dashboard, and Admin panel styles.
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #e0e0e0;
    background-color: #1a1a2e;
    min-height: 100vh;
}

a { color: #4a90d9; }

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

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

.login-box {
    background: #16213e;
    padding: 40px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.login-box h1 {
    margin: 0 0 8px 0;
    font-size: 1.8rem;
    color: #fff;
}

.login-box .subtitle {
    margin: 0 0 24px 0;
    font-size: 0.9rem;
    color: #888;
}

/* ============================================
   FORMS (shared)
   ============================================ */

.form-group {
    margin-bottom: 12px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: #aaa;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #333;
    border-radius: 4px;
    background: #0f3460;
    color: #e0e0e0;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #4a90d9;
}

.error {
    color: #e94560;
    margin-top: 8px;
    min-height: 1.2em;
    font-size: 0.85rem;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #16213e;
    color: #e0e0e0;
    font-size: 0.9rem;
    line-height: 1.4;
    box-sizing: border-box;
    vertical-align: middle;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}

.btn:hover { background: #1a2a4a; }

.btn-primary {
    background: #4a90d9;
    border-color: #4a90d9;
    color: #fff;
}

.btn-primary:hover { background: #3a7bc8; }

.btn-danger {
    background: #e94560;
    border-color: #e94560;
    color: #fff;
}

.btn-danger:hover { background: #c73652; }

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

.btn-launch {
    background: #2ecc71;
    border-color: #2ecc71;
    color: #fff;
}

.btn-launch:hover { background: #27ae60; }

.btn-edit-project {
    background: #e67e22;
    border-color: #e67e22;
    color: #fff;
}

.btn-edit-project:hover { background: #ca6f1e; }

button[type="submit"] {
    width: 100%;
    padding: 12px;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

button[type="submit"]:hover { background: #3a7bc8; }
button[type="submit"]:disabled { background: #555; cursor: not-allowed; }

/* ============================================
   TOP BAR
   ============================================ */

.topbar {
    background: #16213e;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #333;
}

.topbar h1 {
    font-size: 1.2rem;
    color: #fff;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #888;
}

/* ============================================
   BADGES
   ============================================ */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    background: #333;
    color: #aaa;
}

.badge-admin {
    background: #e94560;
    color: #fff;
}

.badge-shared {
    background: #0f9b58;
    color: #fff;
}

/* ============================================
   CONTAINER & PANELS
   ============================================ */

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

.panel {
    background: #16213e;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.panel-header h2 {
    font-size: 1.2rem;
    color: #fff;
}

/* ============================================
   STATS BAR
   ============================================ */

.stats-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    flex: 1;
    background: #16213e;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #4a90d9;
}

.stat-label {
    font-size: 0.8rem;
    color: #888;
    margin-top: 4px;
}

/* ============================================
   DATA TABLE (admin)
   ============================================ */

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

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #333;
}

.data-table th {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    font-weight: normal;
}

.data-table td {
    font-size: 0.9rem;
}

.data-table tr:hover {
    background: rgba(74, 144, 217, 0.05);
}

.loading {
    color: #666;
    text-align: center;
    padding: 20px;
}

/* ============================================
   PROJECT CARDS (dashboard)
   ============================================ */

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

.project-card {
    background: #0f3460;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #333;
    transition: border-color 0.2s;
}

.project-card:hover {
    border-color: #4a90d9;
}

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

.project-header h3 {
    font-size: 1.1rem;
    color: #fff;
    margin: 0;
}

.project-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.project-stat {
    flex: 1;
}

.project-stat .stat-label {
    display: block;
    font-size: 0.7rem;
    color: #888;
}

.project-stat .stat-value {
    display: block;
    font-size: 0.85rem;
    color: #ccc;
    font-weight: normal;
}

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

.empty-state {
    text-align: center;
    color: #666;
    padding: 40px;
    font-size: 1rem;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #16213e;
    border-radius: 8px;
    padding: 32px;
    min-width: 360px;
    max-width: 480px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #fff;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.modal-actions .btn {
    min-width: 80px;
    text-align: center;
}

/* ============================================
   PROJECT SUB-ROWS & USER ROWS (admin)
   ============================================ */

/* Clickable user rows (those with projects) */
.user-row.has-projects {
    cursor: pointer;
}

.user-row.has-projects:hover td {
    background: rgba(74, 144, 217, 0.08);
}

/* Drop target highlight when dragging a project onto a user row */
.user-row.drag-over td {
    background: rgba(74, 144, 217, 0.22) !important;
    outline: 1px solid #4a90d9;
}

.project-toggle {
    color: #4a90d9;
    user-select: none;
}

.toggle-arrow {
    font-size: 0.7rem;
    display: inline-block;
}

.project-sub-row td {
    background: rgba(74, 144, 217, 0.04);
    font-size: 0.85rem;
    color: #bbb;
    border-bottom: 1px solid #2a2a3a;
}

.project-sub-row.dragging td {
    opacity: 0.35;
}

/* Drag handle cell */
.drag-handle {
    cursor: grab;
    color: #444;
    font-size: 0.9rem;
    user-select: none;
    width: 20px;
    text-align: center;
    letter-spacing: -2px;
}

.drag-handle:hover {
    color: #888;
}

.project-sub-name {
    padding-left: 8px !important;
    color: #ccc;
}

.muted-label {
    color: #666;
    font-size: 0.8rem;
}

/* ============================================
   APP LAYOUT & TAB BAR
   ============================================ */

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

#tab-bar {
    display: flex;
    align-items: stretch;
    background: #16213e;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
    min-height: 42px;
}

#tabs {
    display: flex;
    align-items: stretch;
    flex: 1;
    overflow-x: auto;
    gap: 2px;
    padding: 0 4px;
}

#tabs::-webkit-scrollbar { height: 3px; }
#tabs::-webkit-scrollbar-track { background: transparent; }
#tabs::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    font-size: 0.85rem;
    color: #888;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    user-select: none;
    min-width: 80px;
}

.tab:hover { color: #ccc; }

.tab.active {
    color: #fff;
    border-bottom-color: #4a90d9;
}

.tab .close-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    margin-left: 2px;
    border-radius: 3px;
    transition: background 0.15s, color 0.15s;
}

.tab .close-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #ccc;
}

#tab-bar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    flex-shrink: 0;
    border-left: 1px solid #333;
}

#user-info {
    font-size: 0.85rem;
    color: #888;
}

#panels {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.panel-content {
    display: none;
    width: 100%;
    height: 100%;
}

.panel-content.active {
    display: flex;
    flex-direction: column;
}

#panel-dashboard {
    overflow-y: auto;
    flex-direction: column;
}

.dashboard-inner {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
}

/* Terminal panel layout */
.terminal-panel {
    flex-direction: column;
}

.term-status-bar {
    background: #16213e;
    padding: 4px 12px;
    font-size: 0.8rem;
    color: #888;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 14px;
}

.term-conn-status { color: #888; }

.term-idle-warning {
    color: #f39c12;
    font-weight: bold;
}

.term-container {
    flex: 1;
    overflow: hidden;
}

.term-container .xterm {
    height: 100%;
}

.term-mic-btn {
    background: none;
    border: 1px solid #444;
    border-radius: 4px;
    color: #888;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 1px 6px;
    line-height: 1.4;
    transition: background 0.15s, border-color 0.15s;
}

.term-mic-btn:hover {
    background: #1e2d50;
    border-color: #4a90d9;
    color: #ccc;
}

.term-mic-btn.recording {
    background: #4a1010;
    border-color: #e74c3c;
    color: #e74c3c;
    animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.55; }
}

.term-mic-status {
    color: #e74c3c;
    font-size: 0.75rem;
}

/* Rename input in project card */
.rename-input {
    background: #0f3460;
    border: 1px solid #4a90d9;
    border-radius: 4px;
    color: #fff;
    font-size: 1rem;
    padding: 3px 8px;
    width: 100%;
    margin-bottom: 6px;
}

.rename-input:focus {
    outline: none;
    border-color: #7ab4f0;
}

.hidden { display: none !important; }

/* ============================================
   TERMINAL PANEL OVERLAY (dashboard)
   ============================================ */

#terminal-panel {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #1a1a2e;
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

#terminal-panel-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    background: #16213e;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
    gap: 16px;
}

#terminal-panel-title {
    font-size: 0.9rem;
    color: #ccc;
    font-weight: 500;
}

#terminal-panel-status {
    font-size: 0.8rem;
    color: #888;
}

#terminal-panel-warning {
    font-size: 0.8rem;
    color: #f39c12;
    font-weight: bold;
}

#terminal-panel-container {
    flex: 1;
    overflow: hidden;
}

#terminal-panel-container .xterm {
    height: 100%;
}

/* ============================================
   LOG VIEWER OVERLAY (admin)
   ============================================ */

.log-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.log-overlay-content {
    background: #0d1117;
    border: 1px solid #333;
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.log-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #16213e;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.log-overlay-title {
    font-size: 0.9rem;
    color: #ccc;
    font-weight: 500;
    font-family: monospace;
}

.log-overlay-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.log-tail-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: #aaa;
    cursor: pointer;
    user-select: none;
}

.log-content {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    color: #b0c4b1;
    background: #0d1117;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .container { padding: 16px; }
    .stats-bar { flex-direction: column; }
    .projects-grid { grid-template-columns: 1fr; }
    .topbar { padding: 10px 16px; }
    .topbar h1 { font-size: 1rem; }
    .data-table { font-size: 0.8rem; }
    .data-table th, .data-table td { padding: 6px 8px; }
}

@media (max-width: 480px) {
    .login-box { padding: 24px; }
    .modal-content { min-width: auto; margin: 16px; }
    .project-stats { flex-direction: column; gap: 4px; }
}
