/* ==========================================================================
   Locksmith SSH Key Management System - ADA Compliant Stylesheet
   WCAG 2.1 Level AA Compliant
   ========================================================================== */

/* --- Reset and Base --- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #212529;
    background: #f5f5f5;
    margin: 0;
    padding: 0;
}

/* --- Skip to Content (ADA: 2.4.1) --- */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: #0033a0;
    color: #fff;
    padding: 12px 24px;
    z-index: 1000;
    font-size: 1rem;
    text-decoration: none;
    font-weight: bold;
}

.skip-link:focus {
    top: 0;
}

/* --- Focus Indicators (ADA: 2.4.7) --- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible {
    outline: 3px solid #0033a0;
    outline-offset: 2px;
}

a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus,
[role="button"]:focus {
    outline: 3px solid #0033a0;
    outline-offset: 2px;
}

/* --- Header / Banner --- */
.site-header {
    background: #fff;
    border-bottom: 3px solid #0033a0;
    padding: 12px 20px;
    text-align: center;
}

.site-header .header-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.site-header .header-logos img {
    height: 50px;
    width: auto;
}

.site-header .site-title {
    font-size: 1.1rem;
    color: #0033a0;
    margin: 8px 0 0 0;
    font-weight: bold;
}

/* --- Navigation --- */
.site-nav {
    background: #0033a0;
    padding: 8px 20px;
    text-align: center;
}

.site-nav a {
    color: #fff;
    text-decoration: none;
    padding: 8px 16px;
    display: inline-block;
    border-radius: 4px;
    font-size: 0.95rem;
}

.site-nav a:hover,
.site-nav a:focus {
    background: rgba(255, 255, 255, 0.2);
    text-decoration: underline;
}

/* --- Main Content Container --- */
.container {
    max-width: 800px;
    margin: 24px auto;
    padding: 24px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* --- Headings --- */
h1 {
    text-align: center;
    color: #0033a0;
    font-size: 1.75rem;
    margin-top: 0;
}

h2 {
    color: #212529;
    font-size: 1.35rem;
    border-bottom: 2px solid #0033a0;
    padding-bottom: 6px;
    margin-top: 32px;
}

h3 {
    color: #212529;
    font-size: 1.1rem;
}

/* --- Tables (ADA: 1.3.1) --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

table caption {
    font-weight: bold;
    text-align: left;
    padding: 8px 0;
    font-size: 1rem;
    color: #212529;
}

table th,
table td {
    padding: 10px 12px;
    border: 1px solid #ccc;
    text-align: left;
    vertical-align: top;
}

table th {
    background: #f0f4f8;
    font-weight: bold;
    color: #212529;
    width: 35%;
}

/* --- Forms and Labels (ADA: 1.3.1, 3.3.2) --- */
label {
    display: block;
    font-weight: bold;
    margin-bottom: 4px;
    color: #212529;
}

input[type="email"],
input[type="text"],
textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 4px;
    border: 2px solid #767676;
    font-size: 1rem;
    line-height: 1.4;
    color: #212529;
    background: #fff;
}

input[type="email"]:focus,
input[type="text"]:focus,
textarea:focus {
    border-color: #0033a0;
}

textarea {
    height: 150px;
    resize: vertical;
}

.form-help {
    font-size: 0.9rem;
    color: #495057;
    margin-top: -8px;
    margin-bottom: 12px;
}

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

/* --- Buttons (ADA: 2.5.8 touch target 44px min) --- */
button,
.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 12px 24px;
    min-height: 44px;
    min-width: 44px;
    border: 2px solid transparent;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    margin: 5px;
    display: inline-block;
    font-size: 1rem;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    line-height: 1.2;
    transition: background-color 0.15s, box-shadow 0.15s;
}

.btn-primary {
    background: #0033a0;
    border-color: #0033a0;
}

.btn-primary:hover {
    background: #002878;
}

.btn-secondary {
    background: #495057;
    border-color: #495057;
}

.btn-secondary:hover {
    background: #343a40;
}

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

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

button:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-danger:focus-visible {
    box-shadow: 0 0 0 3px #fff, 0 0 0 6px #0033a0;
}

/* --- Link as Button (for login page) --- */
a.btn-primary {
    display: inline-block;
    text-decoration: none;
}

a.btn-primary:hover {
    text-decoration: underline;
}

/* --- SSH Key Display --- */
.key-box {
    background: #f0f4f8;
    padding: 12px;
    border: 2px solid #767676;
    border-radius: 4px;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.85rem;
    word-wrap: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    color: #212529;
}

/* --- Actions Layout --- */
.actions {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.actions .action-btn {
    display: inline;
}

/* --- Flash Messages (ADA: 4.1.3, 1.4.1) --- */
.flash-container {
    margin-bottom: 20px;
}

.flash-container ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.flash-container li {
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 4px;
    border-left: 5px solid;
    font-weight: bold;
}

.flash-container li.success {
    background-color: #d4edda;
    color: #155724;
    border-left-color: #155724;
}

.flash-container li.danger {
    background-color: #f8d7da;
    color: #721c24;
    border-left-color: #721c24;
}

.flash-container li.warning {
    background-color: #fff3cd;
    color: #856404;
    border-left-color: #856404;
}

.flash-container li.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-left-color: #0c5460;
}

/* --- Optional / Muted Text (ADA: 1.4.3 contrast) --- */
.optional {
    font-size: 0.85em;
    color: #495057;
}

.text-muted {
    color: #495057;
}

/* --- Warning Text --- */
.warning-text {
    color: #721c24;
    background: #f8d7da;
    padding: 12px;
    border-radius: 4px;
    border-left: 5px solid #721c24;
    font-weight: bold;
}

/* --- Warning Banner (key sharing prohibition) --- */
.warning-banner {
    background: #fff3cd;
    color: #856404;
    border: 2px solid #856404;
    border-left: 6px solid #856404;
    border-radius: 4px;
    padding: 16px 20px;
    margin: 16px 0 24px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.warning-banner p {
    margin: 0;
}

/* --- Key Card (per-key display on dashboard) --- */
.key-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-left: 5px solid #0033a0;
    border-radius: 4px;
    padding: 16px 20px;
    margin: 16px 0;
}

.key-card h3 {
    margin-top: 0;
    color: #0033a0;
}

/* --- Select Dropdown (ADA: 44px min touch target) --- */
select {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 4px;
    border: 2px solid #767676;
    font-size: 1rem;
    line-height: 1.4;
    color: #212529;
    background: #fff;
    min-height: 44px;
    appearance: auto;
}

select:focus {
    border-color: #0033a0;
}

/* --- Info Text (status messages) --- */
.info-text {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 5px solid #0c5460;
    border-radius: 4px;
    padding: 12px 16px;
    font-weight: bold;
    margin: 12px 0;
}

.info-text a {
    color: #0033a0;
    text-decoration: underline;
}

/* --- Abbreviation Styling --- */
abbr[title] {
    text-decoration: underline dotted;
    cursor: help;
}

/* --- Footer --- */
.site-footer {
    max-width: 1100px;
    margin: 0 auto 24px;
    padding: 16px 24px;
    text-align: center;
    font-size: 0.85rem;
    color: #495057;
    line-height: 1.5;
}

.site-footer a {
    color: #0033a0;
}

.site-footer .footer-links {
    margin-top: 8px;
}

.site-footer .footer-links a {
    margin: 0 8px;
}

/* --- Landing Page Specific --- */
.landing-hero {
    text-align: center;
    padding: 32px 24px;
}

.landing-hero .logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.landing-hero .logos img {
    height: 60px;
    width: auto;
}

.landing-hero h1 {
    font-size: 2rem;
    margin: 16px 0 8px;
}

.landing-hero .subtitle {
    font-size: 1.15rem;
    color: #495057;
    margin-bottom: 32px;
}

.landing-info {
    text-align: left;
    margin: 24px 0;
}

.landing-info h2 {
    text-align: left;
}

.landing-cta {
    text-align: center;
    margin: 32px 0;
}

.landing-cta .btn-primary {
    padding: 16px 40px;
    font-size: 1.2rem;
}

.landing-disclaimer {
    background: #f0f4f8;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 16px;
    margin-top: 24px;
    font-size: 0.9rem;
    color: #495057;
}

.landing-disclaimer h2 {
    font-size: 1.1rem;
    margin-top: 0;
    border-bottom: none;
    padding-bottom: 0;
}

/* --- Confirmation Dialog --- */
.confirm-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    justify-content: center;
    align-items: center;
}

.confirm-overlay.active {
    display: flex;
}

.confirm-dialog {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.confirm-dialog p {
    margin-bottom: 20px;
    font-size: 1rem;
}

.confirm-dialog .confirm-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* ==========================================================================
   Responsive Design (ADA: 1.4.10 Reflow at 320px)
   ========================================================================== */

@media screen and (max-width: 768px) {
    .container {
        margin: 12px;
        padding: 16px;
    }

    h1 {
        font-size: 1.4rem;
    }

    h2 {
        font-size: 1.15rem;
    }

    .site-header .header-logos img {
        height: 40px;
    }

    .site-header .header-logos {
        gap: 16px;
    }

    .landing-hero .logos img {
        height: 45px;
    }

    .landing-hero h1 {
        font-size: 1.5rem;
    }
}

@media screen and (max-width: 480px) {
    .container {
        margin: 8px;
        padding: 12px;
    }

    h1 {
        font-size: 1.25rem;
    }

    /* Stack table rows on mobile */
    table,
    table thead,
    table tbody,
    table tr,
    table th,
    table td {
        display: block;
        width: 100%;
    }

    table tr {
        margin-bottom: 12px;
        border: 1px solid #ccc;
        border-radius: 4px;
    }

    table th {
        background: #f0f4f8;
        border-bottom: none;
        font-weight: bold;
        width: 100%;
    }

    table td {
        border-top: none;
        padding-top: 4px;
    }

    /* Stack action buttons vertically */
    .actions {
        flex-direction: column;
    }

    .actions button,
    .actions .btn-primary,
    .actions .btn-danger {
        width: 100%;
        text-align: center;
    }

    .landing-hero .logos {
        gap: 16px;
    }

    .landing-hero .logos img {
        height: 36px;
    }

    .landing-cta .btn-primary {
        width: 100%;
        padding: 14px 20px;
        font-size: 1.1rem;
    }

    .site-footer .footer-links a {
        display: block;
        margin: 4px 0;
    }
}

/* ===========================================
   Admin Dashboard Styles
   =========================================== */

/* Wider container for admin pages to fit data tables */
.admin-container {
    max-width: 1100px;
}

.admin-header {
    border-bottom: 3px solid #0033a0;
}

.admin-nav {
    background-color: #1a1a2e;
}

/* Admin tables: prevent overflow and improve readability */
.admin-container table {
    table-layout: auto;
    word-break: break-word;
}

.admin-container table th {
    width: auto;
    white-space: nowrap;
}

.admin-container table td {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin: 24px 0;
}

.stat-card {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-left: 4px solid #0033a0;
    padding: 16px 24px;
    flex: 1;
    min-width: 150px;
    text-align: center;
}

.stat-card h3 {
    font-size: 2rem;
    margin: 0;
    color: #0033a0;
}

.stat-card p {
    margin: 4px 0 0;
    color: #495057;
    font-size: 0.9rem;
}

.admin-search {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin: 16px 0;
}

.admin-search .field-group {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}

.admin-search input[type="text"],
.admin-search input[type="date"] {
    width: 100%;
}

.field-inline {
    display: flex;
    flex-direction: column;
    flex: 0 1 auto;
    min-width: 160px;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 16px 0;
    padding: 8px 0;
}

.pagination .page-info {
    font-weight: bold;
    padding: 0 8px;
    color: #212529;
}

.pagination .btn-secondary {
    padding: 8px 16px;
    min-height: 36px;
    font-size: 0.9rem;
}

.page-jump {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
}

.page-jump label {
    display: inline;
    font-weight: normal;
    font-size: 0.9rem;
    margin-bottom: 0;
}

.page-jump input[type="number"] {
    width: 60px;
    padding: 6px 8px;
    margin-bottom: 0;
    font-size: 0.9rem;
}

.page-jump .btn-primary {
    padding: 6px 14px;
    min-height: 36px;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .admin-stats {
        flex-direction: column;
    }

    .admin-search {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-search .field-group {
        min-width: auto;
    }

    .pagination {
        justify-content: center;
    }

    .page-jump {
        margin-left: 0;
        margin-top: 8px;
        width: 100%;
        justify-content: center;
    }
}

/* --- Print Styles --- */
@media print {
    .site-nav,
    .actions,
    .btn-primary,
    .btn-danger,
    .skip-link {
        display: none;
    }

    .container {
        box-shadow: none;
        margin: 0;
        padding: 0;
    }

    body {
        background: #fff;
    }
}
