/**
 * RouteKit Shared CSS
 * Include via: <link rel="stylesheet" href="https://projects.bibby.ie/routekit/routekit.css">
 *
 * Provides consistent styling across all RouteKit projects:
 * - Reset & base typography
 * - Layout containers
 * - Headings & text
 * - Links
 * - Buttons
 * - Forms (inputs, selects, textareas, radio groups, checkboxes)
 * - Alerts
 * - Tables
 * - Cards
 * - Badges
 * - Loading spinner
 * - Lightbox
 * - Accessibility helpers
 * - Footer
 * - Responsive breakpoints
 */

/* ============================================
   RESET & BASE
   ============================================ */

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: Verdana, Geneva, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #000000;
    line-height: 1.6;
}

/* ============================================
   LAYOUT
   ============================================ */

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: #ffffff;
    padding: 30px;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    min-height: calc(100vh - 150px);
}

.container-narrow {
    max-width: 800px;
    margin: 0 auto;
}

.container-form {
    max-width: 400px;
    margin: 0 auto;
}

/* ============================================
   HEADINGS
   ============================================ */

h1 {
    color: #1B5E20;
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.5rem;
    font-weight: bold;
}

h2 {
    color: #2E7D32;
    border-bottom: 2px solid #E8F5E8;
    padding-bottom: 10px;
    margin-top: 30px;
}

h3 {
    color: #1B5E20;
}

/* ============================================
   LINKS
   ============================================ */

a {
    color: #2E7D32;
    text-decoration: none;
}

a:hover {
    color: #1B5E20;
    text-decoration: underline;
}

a:visited {
    color: #2E7D32;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    font-size: 14px;
}

.description {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

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

.btn {
    background-color: #2E7D32;
    color: #ffffff;
    padding: 14px 30px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    display: inline-block;
    text-align: center;
    text-decoration: none;
    font-family: inherit;
}

.btn:hover {
    background-color: #1B5E20;
    color: #ffffff;
    text-decoration: none;
}

a.btn,
a.btn:visited {
    color: #ffffff;
}

a.btn-secondary,
a.btn-secondary:visited {
    color: #000000;
}

a.btn-outline,
a.btn-outline:visited {
    color: #2E7D32;
}

/* Full width for form submit buttons */
button.btn,
input[type="submit"].btn {
    width: 100%;
}

.btn-block {
    display: block;
    width: 100%;
}

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

.btn-primary:hover {
    background-color: #004900;
}

.btn-secondary {
    background-color: #81C784;
    color: #000000;
}

.btn-secondary:hover {
    background-color: #66BB6A;
    color: #000000;
    text-decoration: none;
}

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

.btn-danger:hover {
    background-color: #8B0000;
}

.btn-outline {
    background-color: transparent;
    border: 2px solid #2E7D32;
    color: #2E7D32;
}

.btn-outline:hover {
    background-color: #E8F5E8;
    color: #1B5E20;
}

.btn-outline-danger {
    background-color: transparent;
    border: 2px solid #C62828;
    color: #C62828;
}

.btn-outline-danger:hover {
    background-color: #FFEBEE;
    color: #8B0000;
}

a.btn-outline-danger,
a.btn-outline-danger:visited {
    color: #C62828;
}

.btn-muted {
    background: #f0f0f0;
    color: #555;
    border: 1px solid #bbb;
}

.btn-muted:hover {
    background: #e0e0e0;
}

/* Size modifier: smaller padding and font, always auto-width (compact inline action buttons) */
button.btn-small,
.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
    width: auto;
}

button:disabled,
.btn:disabled {
    background: #689F6B;
    cursor: not-allowed;
    opacity: 0.7;
}

/* ============================================
   FORMS
   ============================================ */

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

label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1B5E20;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #E8F5E8;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #ffffff;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #2E7D32;
}

textarea {
    resize: vertical;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    cursor: pointer;
    margin-right: 6px;
}

.help-text {
    font-size: 0.9rem;
    color: #666;
    margin-top: 5px;
}

.hint {
    font-size: 0.85rem;
    color: #888;
    margin-top: 4px;
}

.optional {
    font-weight: normal;
    color: #666;
    font-size: 0.85rem;
}

/* Radio group */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-option {
    display: flex;
    align-items: center;
    padding: 10px;
    border: 2px solid #E8F5E8;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.radio-option:hover {
    border-color: #2E7D32;
    background-color: #F1F8E9;
}

.radio-option:has(input[type="radio"]:checked) {
    border-color: #2E7D32;
    background-color: #E8F5E8;
}

/* Form block: bordered panel for a repeatable form section (e.g. one item in a
   dynamic list of blocks, rules, or sub-forms). Lighter than .card — intended to
   sit inside a form rather than hold standalone content. */
.form-block {
    border: 1px solid #C8E6C9;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
    background: #FAFDFA;
}

.form-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.form-block-title {
    font-weight: 600;
    font-size: 1.25rem;
    color: #1B5E20;
    margin: 0;
}

/* Empty-state placeholder: dashed-bordered hint shown inside an otherwise-empty
   container (e.g. "no blocks yet — click Add to create one"). Also suitable for
   empty tables, empty search results, etc. */
.empty-state {
    color: #666;
    font-style: italic;
    padding: 15px;
    text-align: center;
    border: 1px dashed #C8E6C9;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-weight: 600;
}

.alert-error {
    background-color: #FFEBEE;
    border: 2px solid #E57373;
    color: #C62828;
}

.alert-success {
    background-color: #E8F5E8;
    border: 2px solid #81C784;
    color: #2E7D32;
}

.alert-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.alert-info {
    background-color: #ebf8ff;
    border: 1px solid #90cdf4;
    color: #2c5282;
}

/* ============================================
   TABLES
   ============================================ */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background-color: #ffffff;
}

th, td {
    padding: 8px 6px;
    text-align: center;
    vertical-align: middle;
    border: 2px solid #000000;
}

th {
    background-color: #06672f;
    color: #ffffff;
    font-weight: 600;
    padding: 10px 8px;
}

tbody tr:nth-child(even) {
    background-color: #E8F5E8;
}

.table-container {
    border: 3px solid #000000;
    border-radius: 8px;
    overflow: hidden;
    background-color: #ffffff;
}

.table-title {
    font-size: 1.3rem;
    font-weight: 600;
    padding: 15px;
    background-color: #004900;
    color: #ffffff;
    text-align: center;
}

/* Light-border table variant (for admin/data tables) */
.table-light th,
.table-light td {
    border: 1px solid #ddd;
    text-align: left;
}

.table-light th {
    background-color: #004900;
    padding: 8px 10px;
}

.table-light td {
    padding: 8px 10px;
    vertical-align: top;
}

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

/* Left-aligned text cells */
td.text-left,
th.text-left {
    text-align: left;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card-green {
    background: #E8F5E8;
    border: none;
}

.card-highlight {
    border-top: 3px solid #2E7D32;
}

/* Tool card (for landing pages / link grids) */
.tool-card {
    background: #E8F5E8;
    padding: 25px;
    border-radius: 8px;
    text-align: center;
    transition: background-color 0.2s;
}

.tool-card:hover {
    background: #d4edda;
}

.tool-card h3 {
    color: #1B5E20;
    margin-top: 0;
}

.tool-card p {
    color: #666;
    margin-bottom: 0;
}

.tool-card-link {
    text-decoration: none;
    color: inherit;
}

.tool-card-link:hover {
    text-decoration: none;
    color: inherit;
}

/* Stat card */
.stat-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #2E7D32;
    text-align: center;
}

.stat-number {
    font-size: 1.8em;
    font-weight: bold;
    color: #1B5E20;
}

.stat-label {
    color: #666;
    font-size: 0.9em;
}

/* ============================================
   GRID LAYOUTS
   ============================================ */

.grid {
    display: grid;
    gap: 20px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

/* ============================================
   FLEX HELPERS
   ============================================ */

.flex-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

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

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

.flex-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #ffffff;
}

.badge-success {
    background: #81C784;
}

.badge-danger {
    background: #E57373;
}

.badge-warning {
    background: #ffc107;
    color: #000000;
}

.badge-info {
    background: #4299e1;
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #E8F5E8;
    border-top: 4px solid #2E7D32;
    border-radius: 50%;
    animation: rk-spin 1s linear infinite;
}

@keyframes rk-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Small spinner for use inside buttons */
.spinner-inline {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: rk-spin 1s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
}

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

.loading-content {
    text-align: center;
    padding: 40px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 2px solid #2E7D32;
}

.loading-content h2 {
    color: #1B5E20;
    margin-bottom: 10px;
    border: none;
}

.loading-content p {
    color: #2E7D32;
}

/* ============================================
   LIGHTBOX
   ============================================ */

.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

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

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

/* ============================================
   AUTH FORMS
   ============================================ */

.auth-container {
    max-width: 400px;
    margin: 0 auto;
}

.auth-description {
    text-align: center;
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

.auth-links {
    text-align: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #E8F5E8;
}

.auth-links p {
    margin: 10px 0;
    color: #666;
}

.auth-links a {
    font-weight: 600;
}

/* ============================================
   METADATA & FOOTER
   ============================================ */

.metadata {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
    font-size: 0.9em;
    color: #666;
}

.footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: #666;
    font-size: 0.9rem;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.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;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #004900;
    color: #ffffff;
    padding: 8px;
    text-decoration: none;
    z-index: 10001;
    border-radius: 0 0 4px 4px;
}

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

a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

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

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 2rem;
    }

    .flex-row {
        flex-direction: column;
    }

    .loading-content {
        margin: 20px;
        padding: 30px;
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 4px 3px;
    }
}
