/* IaC Control Panel - Cisco-inspired Theme */

:root {
    --cisco-blue: #049fd9;
    --cisco-teal: #00bceb;
    --cisco-dark: #1a1a2e;
    --cisco-darker: #0d0d1a;
    --cisco-gray: #6c757d;
    --cisco-light: #f5f5f5;
    --cisco-white: #ffffff;
    --cisco-success: #00c853;
    --cisco-warning: #ffc107;
    --cisco-danger: #ff5252;
    --sidebar-width: 250px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--cisco-light);
    color: #333;
    min-height: 100vh;
}

/* Top Navigation */
.navbar {
    background: linear-gradient(135deg, var(--cisco-dark) 0%, var(--cisco-darker) 100%);
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--cisco-white);
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 600;
}

.navbar-brand .logo {
    width: 36px;
    height: 36px;
    background: var(--cisco-blue);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
}

/* The navbar brand <img> carries class "logo-image"; without an explicit size
   the raw 1024x1024 source renders full-size and overflows onto the page. */
.navbar-brand .logo-image {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--cisco-white);
}

.navbar-user .user-info {
    text-align: right;
}

.navbar-user .user-name {
    font-weight: 500;
}

.navbar-user .user-role {
    font-size: 0.8rem;
    color: var(--cisco-teal);
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--cisco-blue);
    color: var(--cisco-blue);
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-logout:hover {
    background: var(--cisco-blue);
    color: var(--cisco-white);
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--cisco-white);
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-nav {
    padding: 20px 0;
}

.sidebar-section {
    margin-bottom: 20px;
}

.sidebar-section-title {
    padding: 10px 20px;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--cisco-gray);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: var(--cisco-light);
    color: var(--cisco-blue);
}

.sidebar-link.active {
    background: rgba(4, 159, 217, 0.1);
    color: var(--cisco-blue);
    border-left-color: var(--cisco-blue);
}

.sidebar-link .icon {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: 60px;
    padding: 30px;
    min-height: calc(100vh - 60px);
}

/* Page Header */
.page-header {
    margin-bottom: 30px;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--cisco-dark);
    margin-bottom: 8px;
}

.breadcrumb {
    display: flex;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--cisco-gray);
}

.breadcrumb a {
    color: var(--cisco-blue);
    text-decoration: none;
}

/* Cards */
.card {
    background: var(--cisco-white);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--cisco-dark);
}

.card-body {
    padding: 20px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--cisco-white);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--cisco-white);
}

.stat-icon.terraform { background: linear-gradient(135deg, #7b42bc, #5c4ee5); }
.stat-icon.ansible { background: linear-gradient(135deg, #ee0000, #cc0000); }
.stat-icon.jenkins { background: linear-gradient(135deg, #d33833, #b32d29); }
.stat-icon.executions { background: linear-gradient(135deg, var(--cisco-blue), var(--cisco-teal)); }

.stat-content .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--cisco-dark);
}

.stat-content .stat-label {
    color: var(--cisco-gray);
    font-size: 0.9rem;
}

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

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

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: var(--cisco-light);
    font-weight: 600;
    color: var(--cisco-dark);
    font-size: 0.85rem;
    text-transform: uppercase;
}

tr:hover {
    background: rgba(4, 159, 217, 0.03);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: #0388b9;
}

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

.btn-success {
    background: var(--cisco-success);
    color: var(--cisco-white);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: rgba(0, 200, 83, 0.15); color: var(--cisco-success); }
.badge-warning { background: rgba(255, 193, 7, 0.15); color: #e6a800; }
.badge-danger { background: rgba(255, 82, 82, 0.15); color: var(--cisco-danger); }
.badge-info { background: rgba(4, 159, 217, 0.15); color: var(--cisco-blue); }

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--cisco-dark);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--cisco-blue);
    box-shadow: 0 0 0 3px rgba(4, 159, 217, 0.1);
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--cisco-dark) 0%, var(--cisco-darker) 100%);
}

.login-card {
    background: var(--cisco-white);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    width: 60px;
    height: 60px;
    background: var(--cisco-blue);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--cisco-white);
}

.login-title {
    font-size: 1.5rem;
    color: var(--cisco-dark);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--cisco-gray);
}

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

.message {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.message-success { background: rgba(0, 200, 83, 0.1); color: var(--cisco-success); border: 1px solid var(--cisco-success); }
.message-error { background: rgba(255, 82, 82, 0.1); color: var(--cisco-danger); border: 1px solid var(--cisco-danger); }
.message-info { background: rgba(4, 159, 217, 0.1); color: var(--cisco-blue); border: 1px solid var(--cisco-blue); }

/* Footer */
.footer {
    margin-left: var(--sidebar-width);
    padding: 20px 30px;
    text-align: center;
    color: var(--cisco-gray);
    font-size: 0.85rem;
    border-top: 1px solid #eee;
}

/* ===================================
   SECTION 508 ACCESSIBILITY STYLES
   =================================== */

/* Skip Link - Hidden until focused */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--cisco-blue);
    color: var(--cisco-white);
    padding: 12px 24px;
    z-index: 10000;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 4px 0;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--cisco-warning);
    outline-offset: 2px;
}

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

/* Focus Indicators - Enhanced for visibility */
*:focus {
    outline: 3px solid var(--cisco-blue);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 3px solid var(--cisco-blue);
    outline-offset: 2px;
}

/* High contrast focus for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--cisco-warning);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(255, 193, 7, 0.3);
}

/* Ensure minimum touch target size (44x44px) */
.btn,
.sidebar-link,
.btn-logout,
input[type="checkbox"],
input[type="radio"] {
    min-height: 44px;
    min-width: 44px;
}

/* Improved color contrast for text */
.sidebar-section-title {
    color: #595959; /* Improved contrast ratio */
}

/* Active/current page indicator with multiple cues */
.sidebar-link.active {
    background: rgba(4, 159, 217, 0.15);
    color: var(--cisco-blue);
    border-left: 4px solid var(--cisco-blue);
    font-weight: 600;
}

/* Link styling with underline for clarity */
a:not(.btn):not(.sidebar-link):not(.navbar-brand) {
    text-decoration: underline;
}

a:not(.btn):not(.sidebar-link):not(.navbar-brand):hover {
    text-decoration: none;
}

/* Ensure form labels are associated and visible */
.form-label {
    font-weight: 600;
    color: #1a1a1a; /* High contrast */
}

/* Required field indicator */
.form-label.required::after {
    content: " *";
    color: var(--cisco-danger);
}

/* Error messages styling */
.form-error {
    color: var(--cisco-danger);
    font-size: 0.875rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-error::before {
    content: "⚠";
}

/* Input error state */
.form-control.error,
.form-control[aria-invalid="true"] {
    border-color: var(--cisco-danger);
    border-width: 2px;
}

/* Success state */
.form-control.success,
.form-control[aria-invalid="false"] {
    border-color: var(--cisco-success);
    border-width: 2px;
}

/* Improved table accessibility */
table {
    border-collapse: collapse;
    width: 100%;
}

th {
    text-align: left;
    font-weight: 600;
    background: #e8e8e8; /* Higher contrast */
}

/* Alternating row colors for easier reading */
tbody tr:nth-child(even) {
    background: #f9f9f9;
}

/* Row hover with enough contrast */
tbody tr:hover {
    background: rgba(4, 159, 217, 0.1);
}

/* Focus within table rows */
tbody tr:focus-within {
    outline: 2px solid var(--cisco-blue);
    outline-offset: -2px;
}

/* Badge accessibility - ensure text contrast */
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }

/* Message/Alert accessibility */
.message {
    padding: 16px;
    border-radius: 6px;
    margin-bottom: 12px;
    border-left: 4px solid;
}

.message-success {
    background: #d4edda;
    color: #155724;
    border-left-color: var(--cisco-success);
}

.message-error {
    background: #f8d7da;
    color: #721c24;
    border-left-color: var(--cisco-danger);
}

.message-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left-color: var(--cisco-blue);
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --cisco-blue: #0066cc;
        --cisco-dark: #000000;
        --cisco-gray: #333333;
    }

    .sidebar-link.active {
        border-left-width: 6px;
    }

    a {
        text-decoration: underline;
    }

    .btn {
        border: 2px solid currentColor;
    }
}

/* Print styles for accessibility */
@media print {
    .skip-link,
    .sidebar,
    .navbar {
        display: none;
    }

    .main-content {
        margin: 0;
        padding: 20px;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}

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

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

    .footer {
        margin-left: 0;
    }
}
