/**
 * Tile Modals - Kachel-Design für Funktionen & Einstellungen
 */

/* Modal Overlay */
.tile-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.tile-modal.active {
    display: flex;
}

/* Modal Container */
.tile-modal-content {
    background: var(--bg-primary);
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: modalSlideIn 0.25s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Modal Header */
.tile-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.tile-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.tile-modal-header h2 i {
    color: var(--primary-color);
    font-size: 24px;
}

.tile-modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tile-modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Modal Body */
.tile-modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

/* Section Headers */
.tile-section {
    margin-bottom: 24px;
}

.tile-section:last-child {
    margin-bottom: 0;
}

.tile-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.tile-section-header span {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.tile-section-header::before {
    content: '';
    flex: 0 0 4px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 2px;
}

/* Tile Grid */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

/* Individual Tile */
.tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 110px;
    text-align: center;
}

.tile:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tile:active {
    transform: translateY(0);
}

.tile.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Tile Icon */
.tile-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 10px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    color: var(--primary-color);
    transition: all 0.2s;
}

.tile:hover .tile-icon {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

/* Tile Icon Colors */
.tile-icon.green { color: #10b981; }
.tile:hover .tile-icon.green { background: #10b981; color: white; }

.tile-icon.blue { color: #3b82f6; }
.tile:hover .tile-icon.blue { background: #3b82f6; color: white; }

.tile-icon.orange { color: #f59e0b; }
.tile:hover .tile-icon.orange { background: #f59e0b; color: white; }

.tile-icon.red { color: #ef4444; }
.tile:hover .tile-icon.red { background: #ef4444; color: white; }

.tile-icon.purple { color: #8b5cf6; }
.tile:hover .tile-icon.purple { background: #8b5cf6; color: white; }

.tile-icon.cyan { color: #06b6d4; }
.tile:hover .tile-icon.cyan { background: #06b6d4; color: white; }

.tile-icon.pink { color: #ec4899; }
.tile:hover .tile-icon.pink { background: #ec4899; color: white; }

.tile-icon.indigo { color: #6366f1; }
.tile:hover .tile-icon.indigo { background: #6366f1; color: white; }

/* Tile Label */
.tile-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
}

.tile-sublabel {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Admin/Role-based tiles */
.tile.admin-only,
.tile.owner-only,
.tile.org-admin-only {
    display: none;
}

.tile.admin-only.visible,
.tile.owner-only.visible,
.tile.org-admin-only.visible {
    display: flex;
}

/* Tile Badge */
.tile-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--primary-color);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.tile-badge.warning {
    background: #f59e0b;
}

.tile-badge.danger {
    background: #ef4444;
}

/* Tile with badge needs relative positioning */
.tile.has-badge {
    position: relative;
}

/* Responsive */
@media (max-width: 600px) {
    .tile-modal-content {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .tile-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .tile {
        padding: 16px 12px;
        min-height: 100px;
    }

    .tile-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .tile-label {
        font-size: 12px;
    }

    .tile-modal-body {
        padding: 16px;
    }
}

/* Header Buttons for Functions & Settings */
.header-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.header-action-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.header-action-btn i {
    font-size: 16px;
}

/* Hide text on smaller screens */
@media (max-width: 900px) {
    .header-action-btn span {
        display: none;
    }

    .header-action-btn {
        padding: 8px 10px;
    }
}

/* Sub-Modal for Settings Details */
.tile-submodal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2100;
    padding: 20px;
}

.tile-submodal.active {
    display: flex;
}

.tile-submodal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    width: 100%;
    max-width: 700px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: modalSlideIn 0.2s ease-out;
}

.tile-submodal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.tile-submodal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.tile-submodal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(85vh - 60px);
}

.tile-submodal-back {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tile-submodal-back:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
