/* admin.css - Endast admin-specifika stilar */

/* ================================
   Admin-tabell
   ================================ */

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

.admin-table th,
.admin-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.admin-table th {
    background: var(--color-primary);
    color: var(--color-white);
    font-weight: 500;
    white-space: nowrap;
}

.admin-table th:first-child {
    border-radius: 4px 0 0 0;
}

.admin-table th:last-child {
    border-radius: 0 4px 0 0;
}

.admin-table tbody tr:hover {
    background: var(--color-primary-light);
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.order-cell {
    white-space: nowrap;
    width: 80px;
    text-align: center;
}

.actions-cell {
    white-space: nowrap;
    text-align: right;
    min-width: 180px;
}

.actions-cell .btn {
    margin-left: 0.5rem;
    vertical-align: middle;
}

.actions-cell .btn:first-child {
    margin-left: 0;
}

/* ================================
   Sorterbar tabell
   ================================ */

th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.5rem;
}

.admin-table th.sortable:hover {
    background: rgba(0, 0, 0, 0.1);
}

th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 0.5rem;
    opacity: 0.4;
    font-size: 0.8rem;
}

th.sortable.sorted-asc::after {
    content: '↑';
    opacity: 1;
}

th.sortable.sorted-desc::after {
    content: '↓';
    opacity: 1;
}

/* ================================
   Kategori-badge (i tabeller)
   ================================ */

.category-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #fff;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

/* ================================
   Kategori-prick (i checkboxar)
   ================================ */

.category-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    vertical-align: middle;
}

/* ================================
   Status-badges (Ja/Nej)
   ================================ */

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-yes {
    background: #d4edda;
    color: #155724;
}

.status-no {
    background: #f8d7da;
    color: #721c24;
}

/* ================================
   Roll-badges
   ================================ */

.role-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-right: 0.25rem;
}

.role-member {
    background: #e3f2fd;
    color: #1565c0;
}

.role-boarder {
    background: #fff3e0;
    color: #e65100;
}

.role-admin {
    background: #fce4ec;
    color: #c2185b;
}

/* ================================
   Checkbox-grupp (formulär)
   ================================ */

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.checkbox-group .checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: #f8f9fa;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-group .checkbox-label:hover {
    background: var(--color-primary-light);
}

.checkbox-group .checkbox-label input {
    margin: 0;
}

/* ================================
   Inställningsgrupper
   ================================ */

.settings-group {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.settings-group-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    margin: 0;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    color: var(--color-primary);
}

.settings-icon {
    font-size: 1.1rem;
}

.settings-fields {
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.form-group.full-width {
    grid-column: span 2;
}

.settings-fields .form-group:has(textarea) {
    grid-column: span 2;
}

.settings-actions {
    padding: 0 1.25rem 1.25rem;
    border-top: 1px solid #eee;
    margin-top: -0.25rem;
    padding-top: 1rem;
}

.field-description {
    display: block;
    color: #666;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

@media (max-width: 600px) {
    .settings-fields {
        grid-template-columns: 1fr;
    }
    .form-group.full-width,
    .settings-fields .form-group:has(textarea) {
        grid-column: span 1;
    }
}

/* ================================
   Flytande spara-knappar
   ================================ */

.floating-save {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    gap: 0.5rem;
}

.floating-save .btn {
    padding: 12px 24px;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.floating-save .btn:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

/* ================================
   Formulärflikar i modaler
   ================================ */

.form-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #ddd;
}

.form-tab {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: var(--font-family);
}

.form-tab:hover {
    color: #333;
}

.form-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.form-tab-content {
    display: none;
}

.form-tab-content.active {
    display: block;
}

/* ================================
   Readonly-fält
   ================================ */

.form-group input.readonly {
    background: #f5f5f5;
    color: #666;
}

/* ================================
   Boende-lista (lägenheter)
   ================================ */

.residents-list {
    margin-bottom: 1rem;
    overflow-x: auto;
}

.residents-list .admin-table {
    font-size: 0.85rem;
    min-width: 100%;
}

.residents-list .admin-table th,
.residents-list .admin-table td {
    padding: 0.5rem;
    white-space: nowrap;
}

.row-inactive {
    opacity: 0.6;
}

.empty-message {
    color: #666;
    font-style: italic;
}

/* ================================
   Bred modal
   ================================ */

   #modal-form .modal {
    max-width: 600px;
    width: 95%;
}

#modal-form .modal.modal-wide {
    max-width: 1200px;
}

/* ================================
   Typ-badges (kontakter)
   ================================ */

.type-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.type-person {
    background: #e3f2fd;
    color: #1565c0;
}

.type-company {
    background: #f3e5f5;
    color: #7b1fa2;
}

.type-support {
    background: #fff3e0;
    color: #e65100;
}

/* ================================
   Admin-kort med header/body
   ================================ */

.card > .card-header {
    display: block;
    background: #f8f9fa;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #ddd;
    margin-bottom: 0;
}

.card > .card-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--color-primary);
}

.card-body {
    padding: 1.25rem;
}

/* ================================
   Data-tabell (enkel variant)
   ================================ */

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

.data-table th,
.data-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    font-weight: 600;
    color: #666;
    font-size: 0.9rem;
}

/* ================================
   Toggle-switch
   ================================ */

.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
    background-color: #27ae60;
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* ================================
   Logg-badges
   ================================ */

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

/* ================================
   Responsiv admin-tabell
   ================================ */

@media (max-width: 768px) {
    .admin-table thead {
        display: none;
    }
    
    .admin-table,
    .admin-table tbody,
    .admin-table tr,
    .admin-table td {
        display: block;
        width: 100%;
    }
    
    .admin-table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--color-border);
        border-radius: 8px;
        padding: 1rem;
        background: var(--color-white);
    }
    
    .admin-table td {
        border: none;
        padding: 0.25rem 0;
        text-align: left;
    }
    
    .admin-table td:before {
        content: attr(data-label);
        font-weight: 600;
        display: block;
        margin-bottom: 0.25rem;
        color: var(--color-primary);
        font-size: 0.85rem;
    }
    
    .admin-table td[data-label=""]:before {
        display: none;
    }
    
    .admin-table .order-cell,
    .admin-table .actions-cell {
        width: 100%;
        text-align: left;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--color-border);
    }
    
    .admin-table .actions-cell {
        display: flex;
        gap: 0.5rem;
    }
    
    .admin-table .actions-cell .btn {
        flex: 1;
        margin-left: 0;
    }
}

/* Färgförhandsvisning */
.color-preview {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    vertical-align: middle;
    margin-right: 0.5rem;
}

/* ================================
   Info-box (instruktioner)
   ================================ */

.info-box {
    background: #e8f4fc;
    border: 1px solid #b8daef;
    border-left: 4px solid var(--color-primary);
    border-radius: 4px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.info-box p {
    margin: 0;
    line-height: 1.5;
}

.info-box p + p {
    margin-top: 0.5rem;
}

.info-box a {
    color: var(--color-primary);
    font-weight: 500;
}

.info-box a:hover {
    text-decoration: underline;
}

/* ================================
   Underrubrik och tom-state
   ================================ */

.subsection-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: var(--color-text);
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: #666;
    background: #f8f9fa;
    border-radius: 4px;
}

.empty-state p {
    margin: 0;
}

/* ================================
   Filikon och HTML-hjälptext
   ================================ */

.file-icon {
    margin-right: 0.5rem;
}

.html-help {
    display: block;
    margin-top: 0.5rem;
    color: #666;
    line-height: 1.6;
}

.html-help code {
    background: #f0f0f0;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85em;
    color: #333;
}

/* ================================
   Förhandsgranskningsmodal
   ================================ */

.modal-preview {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-preview .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.preview-container {
    background: #fff;
}

.preview-section {
    padding: 1.5rem;
    border-bottom: 1px solid #eee;
}

.preview-section:last-child {
    border-bottom: none;
}

.preview-section h2 {
    margin: 0 0 1rem 0;
    font-size: 1.3rem;
    color: var(--color-primary);
}

.preview-text {
    line-height: 1.6;
}

.preview-text p {
    margin: 0 0 1rem 0;
}

.preview-text p:last-child {
    margin-bottom: 0;
}