/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --success-hover: #15803d;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --border-radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* Login Screen */
.login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--gray-100);
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 48px 40px;
    text-align: center;
    max-width: 420px;
    width: 90%;
}

.login-card .logo {
    max-width: 180px;
    height: auto;
    margin-bottom: 12px;
}

.login-card h1 {
    font-size: 1.75rem;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.login-card .subtitle {
    color: var(--gray-500);
    font-size: 0.95rem;
    margin-bottom: 24px;
}

.login-description {
    color: var(--gray-600);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

.btn-microsoft {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: white;
    color: #5e5e5e;
    border: 1px solid #8c8c8c;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    font-family: 'Segoe UI', sans-serif;
}

.btn-microsoft:hover {
    background: #f5f5f5;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.btn-microsoft:active {
    background: #e8e8e8;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.header-brand {
    flex: 1;
    text-align: center;
}

header .logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 10px;
}

header h1 {
    font-size: 2rem;
    color: var(--gray-900);
    margin-bottom: 5px;
}

header .subtitle {
    color: var(--gray-500);
    font-size: 1rem;
}

/* User Bar */
.user-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    position: absolute;
    top: 20px;
    right: 20px;
}

.user-name {
    font-size: 0.85rem;
    color: var(--gray-600);
    font-weight: 500;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Panels */
.panel {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.panel h2 {
    font-size: 1.25rem;
    color: var(--gray-800);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.panel h3 {
    font-size: 1rem;
    color: var(--gray-700);
    margin-bottom: 12px;
}

/* EC2 Status */
.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 500;
}

.status-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot.offline {
    background: var(--gray-400);
}

.status-dot.starting {
    background: #f59e0b;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-actions {
    display: flex;
    gap: 10px;
}

.details {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
    font-size: 0.9rem;
    color: var(--gray-600);
}

.details p {
    margin-bottom: 4px;
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-300);
}

.btn-large {
    padding: 14px 28px;
    font-size: 1.1rem;
}

/* Forms */
.form-section {
    margin-bottom: 24px;
}

.form-section.collapsible {
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 0;
}

.form-section.collapsible summary {
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
}

.form-section.collapsible summary h3 {
    display: inline;
    margin: 0;
}

.form-section.collapsible > *:not(summary) {
    padding: 0 16px 16px;
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group.full-width {
    flex: 100%;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input::placeholder {
    color: var(--gray-400);
}

.form-actions {
    text-align: center;
    padding-top: 16px;
}

/* Progress */
.progress-container {
    text-align: center;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    position: relative;
}

.progress-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 50px;
    right: 50px;
    height: 2px;
    background: var(--gray-200);
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 1;
}

.step-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: all 0.3s;
}

.step.active .step-icon {
    background: var(--primary);
    color: white;
    animation: pulse 1.5s infinite;
}

.step.completed .step-icon {
    background: var(--success);
    color: white;
}

.step.error .step-icon {
    background: var(--danger);
    color: white;
}

.step-label {
    font-size: 0.85rem;
    color: var(--gray-600);
}

.progress-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Results */
.result-content {
    text-align: center;
    padding: 20px 0;
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.result-icon.success {
    color: var(--success);
}

.result-icon.error {
    color: var(--danger);
}

.result-content h2 {
    border: none;
    padding: 0;
    margin-bottom: 8px;
}

.result-content p {
    color: var(--gray-600);
    margin-bottom: 20px;
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.post-build-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
    text-align: center;
}

.post-build-actions p {
    margin-bottom: 16px;
    color: var(--gray-600);
}

.post-build-actions .btn {
    margin: 0 8px;
}

/* Build History */
#build-history {
    max-height: 300px;
    overflow-y: auto;
}

.build-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.2s;
}

.build-item:hover {
    background: var(--gray-50);
}

.build-item:last-child {
    border-bottom: none;
}

.build-info {
    flex: 1;
}

.build-company {
    font-weight: 500;
    color: var(--gray-800);
}

.build-meta {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.build-actions {
    margin-top: 6px;
    display: flex;
    gap: 12px;
}

.build-link {
    font-size: 0.85rem;
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}

.build-link:hover {
    text-decoration: underline;
    color: var(--primary-hover);
}

.build-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
}

.build-status.success {
    background: #dcfce7;
    color: var(--success);
}

.build-status.running {
    background: #fef3c7;
    color: #d97706;
}

.build-status.error {
    background: #fee2e2;
    color: var(--danger);
}

/* Toast notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    background: var(--gray-800);
    color: white;
    padding: 14px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 350px;
}

.toast.error {
    background: var(--danger);
}

.toast.success {
    background: var(--success);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

.loading {
    text-align: center;
    color: var(--gray-500);
    padding: 20px;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    .status-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .status-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .status-actions .btn {
        flex: 1;
    }

    .form-row {
        flex-direction: column;
    }

    .form-group {
        min-width: 100%;
    }

    .progress-steps {
        flex-wrap: wrap;
        gap: 20px;
    }

    .progress-steps::before {
        display: none;
    }
}
