/* Reusable Admin Components Styles
 * Note: Shared form and autocomplete styles moved to shared-components.css
 *
 * Includes:
 * - Admin layout styles (merged from admin-layout.css)
 * - Admin statistics styles (merged from admin-statistics.css)
 * - Admin roles styles (merged from admin-roles.css)
 */

/* Form sections */
.admin-form {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--card-shadow);
    margin-bottom: 30px;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.edit-section {
    margin-bottom: 40px;
}

.edit-section h2,
.edit-section h3 {
    color: var(--text-primary);
    margin-bottom: 20px;
}

.table-section {
    margin-top: 40px;
}

.table-section h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
}

.no-data {
    text-align: center;
    color: var(--text-tertiary);
    padding: 40px 20px;
    font-style: italic;
    background: var(--card-bg);
    border-radius: 12px;
}

.text-muted {
    color: var(--text-tertiary);
}

.required {
    color: #dc3545;
}

/* Checkbox inputs */
input[type="checkbox"] {
    margin-right: 8px;
    width: auto;
    cursor: pointer;
}

.form-group label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.modal-form .form-group label:has(input[type="checkbox"]) {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    width: auto;
    font-size: 1em;
    margin-bottom: 0;
}

/* Admin header */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
}

.admin-header h1 {
    margin: 0;
    font-size: 2em;
    color: var(--text-primary);
}

.admin-header > div {
    display: flex;
    gap: 10px;
}

/* Brand logo preview in header */
.brand-logo-preview img {
    max-width: 500px;
    max-height: 120px;
    object-fit: contain;
}

/* Close button for modals */
.close-btn {
    background: none;
    border: none;
    font-size: 2em;
    color: var(--text-tertiary);
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: var(--text-primary);
}

/* Select with inline-add button */
.select-with-add-container {
    margin-bottom: 20px;
}

.select-with-add-container label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 0.95em;
}

.select-with-add-group {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.form-select {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    background: var(--input-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.3s ease;
    font-family: inherit;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

@media (prefers-color-scheme: dark) {
    .form-select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b0b0b0' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    }
}

.form-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.inline-add-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.inline-add-button svg {
    width: 16px;
    height: 16px;
}

.inline-add-button:hover {
    background: var(--accent-secondary);
}

.inline-add-button:active {
    transform: translateY(1px);
}


/* File upload */
.file-upload-group {
    margin-bottom: 20px;
}

.file-upload-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-input {
    display: none;
}

.file-upload-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--accent-primary);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-weight: 500;
    white-space: nowrap;
}

.modal-form .form-group .file-upload-label {
        color: white;
}

.file-upload-label svg {
    width: 18px;
    height: 18px;
}

.file-upload-label:hover {
    background: var(--accent-secondary);
}

.file-name {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.file-preview {
    display: none;
    margin-top: 15px;
    padding: 15px;
    background: var(--hover-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.file-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 4px;
}

.file-info p {
    margin: 5px 0;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.action-buttons > * {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-edit,
.btn-delete,
.btn-custom {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-edit {
    background: var(--accent-primary);
    color: white;
}

.btn-edit:hover {
    background: var(--accent-secondary);
}

.btn-edit svg,
.btn-delete svg,
.btn-custom svg {
    width: 18px;
    height: 18px;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

.btn-custom {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-custom:hover {
    border-color: var(--accent-primary);
    background: var(--hover-bg);
}

/* Data tables */
.data-table-container {
    overflow-x: auto;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--card-shadow);
}

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

.data-table thead {
    background: var(--hover-bg);
}

.data-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: var(--hover-bg);
}

.data-table tbody tr.selected {
    background: var(--hover-bg-alt);
}

.empty-state {
    text-align: center;
    color: var(--text-tertiary);
    padding: 40px 20px !important;
    font-style: italic;
}

/* Notification toast */
.notification-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: 500;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    z-index: 10000;
    max-width: 400px;
}

.notification-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.notification-success {
    background: var(--comparison-above-bg);
    color: var(--comparison-above-text);
    border: 1px solid var(--comparison-above-text);
}

.notification-error {
    background: var(--error-bg);
    color: white;
}

.notification-warning {
    background: var(--comparison-equal-bg);
    color: var(--comparison-equal-text);
    border: 1px solid var(--comparison-equal-text);
}

.notification-info {
    background: var(--accent-primary);
    color: white;
}

/* Modal overrides for component modals */
.modal-body {
    padding: 20px 30px 30px;
}

/* Responsive design */
@media (max-width: 768px) {
    .select-with-add-group {
        flex-direction: column;
    }

    .inline-add-button {
        width: 100%;
        justify-content: center;
    }

    .file-upload-container {
        flex-direction: column;
        align-items: stretch;
    }

    .file-upload-label {
        justify-content: center;
    }

    .action-buttons {
        justify-content: flex-start;
    }

    .notification-toast {
        left: 20px;
        right: 20px;
        max-width: none;
    }

    .data-table {
        font-size: 0.9em;
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px;
    }
}

/* History section */
.history-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
}

.history-section h3 {
    display: inline-block;
    margin: 0 0 20px 0;
    font-size: 1.3em;
    color: var(--text-primary);
}

.history-section > h3 + button,
.history-section > h3 + .btn-secondary,
.history-section > h3 + .btn-primary {
    float: right;
    margin-top: -5px;
}

.history-section::after {
    content: "";
    display: table;
    clear: both;
}


/* Print styles */
@media print {
    .inline-add-button,
    .action-buttons,
    .file-upload-label,
    .notification-toast {
        display: none;
    }
}

/* ==============================================
   ADMIN LAYOUT (merged from admin-layout.css)
   ============================================== */

/* Section header with actions */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-actions {
    display: flex;
    gap: 10px;
}

/* Sections with spacing */
.admin-section-spaced {
    margin-top: 40px;
}

/* Grids */
.seasons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.logos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

/* Seasons as compact labels */
.seasons-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.season-label {
    display: inline-flex;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 8px 6px 12px;
    font-size: 0.95em;
    transition: all 0.2s ease;
}

.season-label:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.season-year {
    color: var(--text-primary);
    font-weight: 500;
    margin-right: 6px;
}

.season-delete-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3em;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    margin-left: 2px;
    transition: color 0.2s ease;
    font-weight: 300;
}

.season-delete-btn:hover {
    color: var(--danger-color);
}

/* Season card */
.season-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.season-card h4 {
    margin: 0 0 10px 0;
    font-size: 1.2em;
    color: var(--text-primary);
}

.season-card form {
    display: inline;
}

/* Badge */
.badge {
    background: var(--primary-color);
    color: var(--text-tertiary);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    margin-left: 10px;
}

/* Drop zone positioning */
.drop-zone-container {
    position: relative;
}

/* Stats grid (layout version) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.stat-card h3 {
    margin: 0 0 5px 0;
    font-size: 2em;
    color: var(--primary-color);
}

.stat-card p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Form help text */
.form-help {
    display: block;
    color: var(--text-tertiary);
    font-size: 0.85em;
    margin-top: 5px;
}

/* ==============================================
   ADMIN STATISTICS (merged from admin-statistics.css)
   ============================================== */

/* Stats Grid - Statistics page specific */
.stats-grid.stats-page {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

/* Stat Card - Statistics page specific */
.stat-card.stats-page {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 12px;
}

.stat-label {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2.5em;
    font-weight: 700;
    color: var(--accent-primary);
}

.stat-description {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Popular Content Grid */
.popular-content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 40px;
}

/* Popular Section */
.popular-section {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.popular-section h2 {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* Popular List Table */
.popular-list table {
    width: 100%;
    border-collapse: collapse;
}

.popular-list thead tr {
    border-bottom: 2px solid var(--border-color);
}

.popular-list th {
    text-align: left;
    padding: 12px 8px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9em;
}

.popular-list th:last-child {
    text-align: right;
}

.popular-list tbody tr {
    border-bottom: 1px solid var(--border-color);
}

.popular-list td {
    padding: 12px 8px;
}

.popular-list .rank-cell {
    color: var(--text-primary);
    font-weight: 600;
}

.popular-list .logo-info {
    display: flex;
    flex-direction: column;
}

.popular-list .logo-name {
    color: var(--text-primary);
    font-weight: 500;
}

.popular-list .logo-details {
    color: var(--text-secondary);
    font-size: 0.85em;
}

.popular-list .company-link {
    color: var(--accent-primary);
    text-decoration: none;
}

.popular-list .company-link:hover {
    text-decoration: underline;
}

.popular-list .download-count {
    text-align: right;
    color: var(--text-primary);
    font-weight: 600;
}

.popular-list .no-data {
    color: var(--text-secondary);
    padding: 20px 0;
}

/* ==============================================
   ADMIN ROLES (merged from admin-roles.css)
   ============================================== */

/* Roles grid layout */
.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Role card */
.role-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px var(--card-shadow);
    transition: box-shadow 0.3s ease;
}

.role-card:hover {
    box-shadow: 0 6px 20px var(--card-shadow);
}

.role-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.role-card-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
}

.role-card-body {
    min-height: 100px;
}

.role-card-body h4 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Permissions list in role cards */
.permissions-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.permissions-list li {
    padding: 6px 0;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

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

.permissions-list li::before {
    content: "✓ ";
    color: var(--comparison-above-text, #28a745);
    font-weight: bold;
    margin-right: 5px;
}

.no-permissions {
    color: var(--text-tertiary);
    font-style: italic;
    font-size: 14px;
}

/* Modal overrides for roles */
#edit-permissions-modal .modal-content {
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

#edit-permissions-modal .modal-body {
    overflow-y: auto;
    flex: 1;
}

#edit-permissions-modal #permissions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Permission category sections in modal */
.permission-category {
    flex: 1 1 300px;
    min-width: 250px;
    margin-bottom: 20px;
}

/* Permission category sections in overview */
.permissions-overview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.permission-category-overview {
    background: var(--hover-bg, rgba(0, 0, 0, 0.02));
    border-radius: 8px;
    padding: 12px;
}

.permission-category-overview h5 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.permission-category-overview .permissions-list {
    margin: 0;
}

.permission-category-overview .permissions-list li {
    padding: 4px 0;
    font-size: 13px;
}

.permission-category h5 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Permission checkbox items */
.permission-checkbox {
    display: flex;
    align-items: center;
    padding: 8px 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.permission-checkbox:hover {
    background: var(--hover-bg);
}

.permission-checkbox input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
}

.permission-checkbox label {
    cursor: pointer;
    flex: 1;
    color: var(--text-primary);
}

/* Subtitle text */
.subtitle {
    color: var(--text-secondary);
    margin-top: 5px;
    font-size: 14px;
}

/* Responsive design for roles */
@media (max-width: 768px) {
    .roles-grid {
        grid-template-columns: 1fr;
    }

    #edit-permissions-modal .modal-content {
        width: 95%;
        max-width: 95%;
    }

    #edit-permissions-modal #permissions-list {
        flex-direction: column;
    }

    .permission-category {
        min-width: 100%;
    }

    .permissions-overview {
        grid-template-columns: 1fr;
    }
}
