/* Reset and base styles */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --background-color: #f8f9fa;
    --text-color: #333333;
    --border-color: #dee2e6;
    --header-bg: #2c3e50;
    --footer-bg: #2c3e50;
    --link-color: #3498db;
    --link-hover-color: #2980b9;
    --error-color: #e74c3c;
    --success-color: #2ecc71;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

a:hover {
    color: var(--link-hover-color);
}

/* Layout */
.container {
    width: 100%;
    max-width: 1100px; /* 1100px total width */
    margin: 0 auto;
    padding: 0 100px; /* 100px padding on both sides */
}

main {
    flex: 1;
    padding: 2rem 0;
}

/* Add responsive adjustments for smaller screens */
@media (max-width: 1024px) {
    .container {
        padding: 0 50px; /* Reduce padding on medium screens */
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 20px; /* Further reduce padding on mobile screens */
    }
}

/* Header */
header {
    background-color: var(--header-bg);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

nav.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    position: relative;
}

nav.top .logo {
    display: block;
    width: 210px;
    height: 40px;
    background-image: url('/assets/img/RaceBoxLogoWhite.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

nav.top .menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

nav.top .menu a {
    color: white;
    text-decoration: none;
    padding: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.2s ease-in-out;
}

nav.top .menu a:hover {
    color: var(--accent-color);
}

/* Hamburger menu */
.menu-toggle {
    display: none;
}

.hamburger {
    cursor: pointer;
    padding: 0.5rem;
    width: 30px;
    height: 30px;
    display: none; /* Initially hidden */
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    margin: 4px 0;
    background: white;
    transition: all 0.3s ease-in-out;
    transform-origin: center;
}

/* Mobile styles */
@media (max-width: 768px) {
    nav.top {
        padding: 0.5rem 1rem;
    }

    .hamburger {
        display: block;
    }

    nav.top .menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        background-color: var(--header-bg);
        padding: 0;
        gap: 0;
        transform: translateY(-20px);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease-in-out;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }

    nav.top .menu-toggle:checked ~ .menu {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
}

/* Footer */
footer {
    background-color: var(--footer-bg);
    color: white;
    padding: 2rem 0;
    margin-top: auto;
}

/* Alert messages */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    border: 1px solid transparent;
}

.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* Responsive design */
@media (max-width: 768px) {
    nav.top {
    }

    nav.top div {

    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
    h5 { font-size: 1.15rem; }
    h6 { font-size: 1rem; }

    nav.top .menu a {
        text-align: center;
        padding: 0.75rem;
    }
}

/* Utility classes */
.text-center { text-align: center; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

/* Applications List Styles */
.applications-list, .tokens-list, .users-list, .bundles-list, .projects-list {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin: 1rem 0;
}

.bundle-filter {
    margin-bottom: 1rem;
}

.bundle-filter select {
    width: 100%;
    max-width: 400px;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Common mobile card layout for all list views */
@media (max-width: 768px) {
    .list-header {
        display: none;
    }

    .list-item {
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        background: white;
    }

    .list-item:last-child {
        border-bottom: none;
    }

    .label {
        display: inline-block;
        font-weight: 500;
        min-width: 80px;
        margin-right: 0.5rem;
        color: var(--text-muted);
    }

    /* Common name/title styling */
    .col-name, .col-bundle-id, .col-email {
        font-size: 1.1rem;
        font-weight: 500;
    }

    /* Actions styling for all lists */
    .col-actions {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border-color);
        display: flex;
        gap: 1rem;
    }

    .col-actions a {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.75rem;
        background: var(--background-color);
        border-radius: 4px;
        text-decoration: none;
    }

    .col-actions a:hover {
        background: var(--border-color);
    }

    /* Token specific styles */
    .token-container {
        margin: 0.5rem 0;
    }

    .token-container code {
        word-break: break-all;
    }

    /* List container styling */
    .list-container {
        background: white;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        margin: 1rem 0;
        overflow: hidden;
    }

    /* Make icons slightly larger on mobile for better touch targets */
    .icon {
        width: 28px;
        height: 28px;
    }

    /* Mobile responsive for reference sections */
    .users-reference .reference-item,
    .bundles-reference .reference-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .user-actions,
    .bundle-actions {
        justify-content: flex-start;
    }
}

/* Desktop styles remain unchanged */
@media (min-width: 769px) {
    .list-header {
        display: grid;
        padding: 1rem;
        gap: 1rem;
        align-items: center;
        background: var(--header-bg);
        color: white;
        font-weight: 500;
        border-radius: 8px 8px 0 0;
    }

    .list-header, .list-item {
        display: grid;
        padding: 1rem;
        gap: 1rem;
        align-items: center;
    }

    .list-item > div {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Grid templates for different lists */
    .applications-list .list-header,
    .applications-list .list-item {
        grid-template-columns: 40px 2fr 1fr 1fr 1.5fr 100px;
    }

    .tokens-list .list-header,
    .tokens-list .list-item {
        grid-template-columns: 2fr 1fr 1fr 1fr 1fr 100px;
    }

    .users-list .list-header,
    .users-list .list-item {
        grid-template-columns: 2fr 2fr 1.5fr 1fr 100px;
    }

    .bundles-list .list-header,
    .bundles-list .list-item {
        grid-template-columns: 1fr 1fr 1fr 2fr 100px;
    }

    .projects-list .list-header,
    .projects-list .list-item {
        grid-template-columns: 2fr 3fr 1fr 100px;
    }

    .label {
        display: none;
    }
}

/* Common styles for both layouts */
.platform-icon {
    width: 24px;
    height: 24px;
}

.col-actions {
    display: flex;
    gap: 0.5rem;
}

.icon {
    width: 24px;
    height: 24px;
}

/* Platform icons */
.platform-icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    vertical-align: middle;
}

.platform-icon.ipa {
    background-image: url('/assets/img/ios-icon.svg');
}

.platform-icon.apk {
    background-image: url('/assets/img/android-icon.svg');
}

/* Action icons */
.icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    vertical-align: middle;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.icon:hover {
    opacity: 1;
}

.icon.download {
    background-image: url('/assets/img/download-icon.svg');
}

.icon.delete {
    background-image: url('/assets/img/delete-icon.svg');
}

.icon.edit {
    background-image: url('/assets/img/edit-icon.svg');
}

.icon.chevron-right {
    background-image: url('/assets/img/chevron-right-icon.svg');
}

/* Access badges */
.access-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.access-badge.admin {
    background-color: #e3f2fd;
    color: #1976d2;
}

.access-badge.all {
    background-color: #e8f5e8;
    color: #2e7d32;
}

.access-badge.limited {
    background-color: #fff3e0;
    color: #f57c00;
}

/* Project access form styling */
.project-access-info {
    margin-bottom: 0.5rem;
}

.project-access-info p {
    margin: 0;
    color: #666;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-group label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-group label small {
    color: #666;
    margin-left: 0.25rem;
}

/* Project reference sections */
.project-references {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.project-references h2 {
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.reference-section {
    margin-bottom: 2rem;
}

.reference-section h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.1rem;
}

.reference-list {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.reference-item {
    display: grid;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    gap: 1rem;
}

.reference-item:last-child {
    border-bottom: none;
}

/* Users reference specific styling */
.users-reference .reference-item {
    grid-template-columns: 2fr 1fr auto;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.user-email {
    color: #666;
    font-size: 0.875rem;
}

.user-access-type {
    display: flex;
    justify-content: flex-start;
}

.user-actions {
    display: flex;
    gap: 0.5rem;
}

/* Bundles reference specific styling */
.bundles-reference .reference-item {
    grid-template-columns: 2fr 2fr auto;
}

.bundle-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bundle-id {
    color: #666;
    font-size: 0.875rem;
    font-family: monospace;
}

.bundle-description {
    color: #666;
    font-size: 0.875rem;
}

.bundle-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: var(--background-color);
    border-radius: 4px;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.btn-link:hover {
    background: var(--border-color);
}

.no-items {
    color: #666;
    font-style: italic;
    margin: 1rem 0;
}

/* Actions column */
td.actions {
    white-space: nowrap;
    text-align: right;
    min-width: 100px;
}

td.actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 6px;
    margin-left: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

td.actions a:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

td.actions a.delete-link:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

/* Status indicators */
tr.deleted td {
    opacity: 0.6;
}

/* File size and date columns */
td.file-size {
    white-space: nowrap;
    text-align: right;
    padding-right: 2rem;
}

td.date {
    white-space: nowrap;
}

/* Form styles */
fieldset {
    border: none;
    padding: 0;
    margin: 0 0 2rem 0;
}

fieldset legend {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
    max-width: 400px;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.95rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-color);
    background-color: white;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-actions {
    max-width: 400px;
}

/* Buttons */
.btn,
button[type="submit"],
a.button-secondary {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    line-height: 1.5;
    border: 1px solid transparent;
}

.btn,
button[type="submit"] {
    background-color: var(--header-bg);
    color: white;
}

a.button-secondary {
    background-color: var(--background-color);
    color: var(--text-color);
    border-color: var(--border-color);
}

.btn:hover,
button[type="submit"]:hover {
    background-color: var(--secondary-color);
    transform: translateY(-1px);
    color: white;
}

a.button-secondary:hover {
    background-color: var(--border-color);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--header-bg);
    color: var(--header-bg);
}

.btn-secondary:hover {
    background-color: rgba(44, 62, 80, 0.1);
    border-color: var(--secondary-color);
    color: var(--header-bg); /* Keep original text color on hover */
}

/* Form error styles */
.form-errors {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: 8px;
    background-color: var(--error-color);
    color: white;
}

.form-errors ul {
    margin: 0;
    padding-left: 1.5rem;
}

.form-errors li {
    margin-bottom: 0.25rem;
}

.form-errors li:last-child {
    margin-bottom: 0;
}

/* Form layout container */
.form-container {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .form-container {
        margin: 1rem auto;
        padding: 1.5rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .btn,
    button[type="submit"] {
        margin-bottom: 0.5rem;
    }
}

.form-spacer {
    margin: 2rem 0;
    border-top: 1px solid #eee;
}

.flash-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #4CAF50;
    color: white;
    padding: 1rem 2rem;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.flash-message.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.token-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.copy-button {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.copy-button:hover {
    opacity: 1;
}

.icon.copy {
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='13' height='13' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.latest-version-banner {
    display: none;  /* Hidden by default on desktop */
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 1rem;
    margin-bottom: 2rem;
    align-items: center;
    gap: 1rem;
}

@media (max-width: 768px) {
    .latest-version-banner {
        display: flex;  /* Only show on mobile */
    }
}

.latest-version-banner .version-info {
    flex-grow: 1;
    font-weight: 500;
}

.latest-version-banner .download-button {
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    white-space: nowrap;
}

.latest-version-banner .download-button:hover {
    background: var(--primary-color-dark);
}

/* Application Details Page */
.application-details {
    max-width: 800px;
    margin: 2rem auto;
    padding: 1rem;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.detail-item {
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.detail-item label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
}

.detail-item span {
    font-size: 1.1rem;
    color: var(--text-color);
}

/* Responsive adjustments for application details */
@media (max-width: 768px) {
    .application-details {
        margin: 1rem auto;
    }

    .details-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin: 1.5rem 0;
    }
}
