/*
 * Orchestrator Main Stylesheet
 * Traditional CSS with semantic class names
 */

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    color: #111827;
    background-color: #f3f4f6;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: #111827;
}

.monospace {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

/* ============================================
   LAYOUT
   ============================================ */
.page-container {
    min-height: 100vh;
    background: linear-gradient(to bottom right, #f9fafb, #f3f4f6);
}

.page-header {
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.header-content {
    max-width: 80rem;
    margin: 0 auto;
    padding: 1.25rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
}

.site-title svg {
    width: 2rem;
    height: 2rem;
    margin-right: 0.75rem;
    color: #2563eb;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.username-display {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.main-content {
    max-width: 80rem;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

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

.btn-primary {
    background-color: #047857;
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background-color: #065f46;
}

.btn-secondary {
    background-color: #334155;
    color: #ffffff;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #1e293b;
}

.btn-danger {
    background-color: #be123c;
    color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
    background-color: #9f1239;
}

.btn-warning {
    background-color: #d97706;
    color: #ffffff;
}

.btn-warning:hover:not(:disabled) {
    background-color: #b45309;
}

.btn-login {
    background-color: #1e3a8a;
    color: #ffffff;
    padding: 0.75rem 1rem;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.btn-login:hover {
    background-color: #172554;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* ============================================
   FORMS
   ============================================ */
.form-input {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.15s ease;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input::placeholder {
    color: #9ca3af;
}

.password-input-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.375rem;
}

.password-toggle:hover {
    color: #4b5563;
}

/* ============================================
   CARDS & PANELS
   ============================================ */
.card {
    background-color: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    border: 1px solid #e5e7eb;
}

.card-body {
    padding: 1.5rem;
}

.section-divider {
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

/* ============================================
   DASHBOARD COMPONENTS
   ============================================ */
.dashboard-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.launch-controls {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.instance-counter {
    display: inline-flex;
    border: 2px solid #d1d5db;
    border-radius: 0.5rem;
    background-color: #ffffff;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    overflow: hidden;
}

.counter-button {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    background-color: transparent;
    border: none;
    border-right: 1px solid #d1d5db;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.counter-button:last-child {
    border-right: none;
}

.counter-button:hover {
    background-color: #f3f4f6;
}

.counter-button.selected {
    background-color: rgba(59, 130, 246, 0.2);
}

.status-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.running-count {
    font-size: 0.875rem;
    color: #4b5563;
}

.running-count strong {
    font-weight: 700;
    color: #111827;
}

/* ============================================
   TABLES
   ============================================ */
.instances-table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
}

.instances-table thead {
    background: linear-gradient(to right, #f9fafb, #f3f4f6);
}

.instances-table th {
    padding: 0.75rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.instances-table tbody {
    background-color: #ffffff;
}

.instances-table tbody tr {
    border-top: 1px solid #e5e7eb;
    transition: background-color 0.15s ease;
}

.instances-table tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

.instances-table tbody tr:hover {
    background-color: #eff6ff;
}

.instances-table td {
    padding: 1rem 1.5rem;
    white-space: nowrap;
}

.instance-name {
    display: flex;
    align-items: center;
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    margin-right: 0.75rem;
}

.status-dot.running {
    background-color: #22c55e;
}

.status-dot.stopped {
    background-color: #eab308;
}

.instance-name-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
}

.instance-ip {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    font-weight: 500;
    color: #111827;
}

.instance-ip.clickable {
    cursor: pointer;
}

.instance-ip.clickable:hover {
    color: #2563eb;
}

.copy-button {
    margin-left: 0.5rem;
    padding: 0.375rem;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 0.25rem;
    transition: all 0.15s ease;
}

.copy-button:hover {
    color: #4b5563;
    background-color: #f3f4f6;
}

.status-badge {
    display: inline-flex;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}

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

.status-badge.stopped {
    background-color: #fef3c7;
    color: #854d0e;
}

.instance-timer {
    font-size: 1.125rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-weight: 700;
    color: #111827;
}

.instance-timer.expiring-soon {
    color: #dc2626;
}

.instance-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================================
   ALERTS & MESSAGES
   ============================================ */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    border: 2px solid;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.alert-success {
    background-color: #f0fdf4;
    border-color: #86efac;
}

.alert-success .alert-content {
    color: #166534;
}

.alert-error {
    background-color: #fef2f2;
    border-color: #fca5a5;
}

.alert-error .alert-content {
    color: #991b1b;
}

.alert-info {
    background-color: #eff6ff;
    border-color: #93c5fd;
}

.alert-info .alert-content {
    color: #1e40af;
}

.alert-body {
    display: flex;
    align-items: center;
}

.alert-icon {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
}

.alert-content {
    font-size: 0.875rem;
    font-weight: 500;
}

/* ============================================
   LOADING & MODALS
   ============================================ */
.loading-mask {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.loading-mask.hidden {
    display: none;
}

.loading-content {
    background-color: #ffffff;
    border-radius: 0.5rem;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.spinner {
    width: 3rem;
    height: 3rem;
    color: #2563eb;
    margin-bottom: 1rem;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    color: #374151;
    font-weight: 500;
}

.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(107, 114, 128, 0.5);
    overflow-y: auto;
    height: 100%;
    width: 100%;
    z-index: 50;
}

.modal.hidden {
    display: none;
}

.modal-dialog {
    position: relative;
    top: 5rem;
    margin: 0 auto;
    padding: 1.25rem;
    max-width: 24rem;
    width: 100%;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    border-radius: 0.375rem;
}

.modal-header {
    margin-top: 0.75rem;
    text-align: center;
}

.modal-icon-wrapper {
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 9999px;
    background-color: #fef3c7;
}

.modal-icon {
    width: 1.5rem;
    height: 1.5rem;
    color: #ca8a04;
}

.modal-title {
    font-size: 1.125rem;
    line-height: 1.5rem;
    font-weight: 500;
    color: #111827;
    margin-top: 1rem;
}

.modal-body {
    margin-top: 0.5rem;
    padding: 0 1.75rem 0.75rem;
}

.modal-text {
    font-size: 0.875rem;
    color: #6b7280;
}

.modal-countdown {
    font-weight: 700;
    color: #dc2626;
}

.modal-footer {
    padding: 0 1rem 0.75rem;
}

.modal-button {
    width: 100%;
    padding: 0.5rem 1rem;
    background-color: #2563eb;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    transition: all 0.15s ease;
}

.modal-button:hover {
    background-color: #1d4ed8;
}

.modal-button:focus {
    outline: none;
    box-shadow: 0 0 0 2px #3b82f6;
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
    text-align: center;
    color: #6b7280;
    padding: 3rem 0;
}

.empty-state-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    color: #d1d5db;
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 500;
    color: #111827;
}

.empty-state-text {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.loading-state {
    text-align: center;
    color: #6b7280;
    padding: 2rem 0;
}

.loading-state-icon {
    width: 2rem;
    height: 2rem;
    margin: 0 auto;
    color: #3b82f6;
    animation: spin 1s linear infinite;
}

.loading-state-text {
    margin-top: 0.5rem;
}

/* ============================================
   ALERTS (SHARED ACROSS PAGES)
   ============================================ */
.alert {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid;
}

.alert.alert-error {
    background-color: #fef2f2;
    border-color: #ef4444;
}

.alert.alert-error .alert-message {
    color: #b91c1c;
}

.alert.alert-info {
    background-color: #eff6ff;
    border-color: #3b82f6;
}

.alert.alert-info .alert-message {
    color: #1d4ed8;
}

.alert.alert-success {
    background-color: #f0fdf4;
    border-color: #86efac;
}

.alert.alert-success .alert-message {
    color: #166534;
}

.alert-message {
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
}

.alert-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-icon-text {
    display: flex;
    align-items: center;
    flex: 1;
}

.alert-icon {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.alert-icon-success {
    color: #16a34a;
}

.alert-icon-error {
    color: #dc2626;
}

.alert-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
    margin-left: 1rem;
}

.alert-close-btn:hover {
    opacity: 0.75;
}

.alert-close-icon {
    width: 1rem;
    height: 1rem;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 640px) {
    .header-content,
    .main-content {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .header-content,
    .main-content {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}
